Skip to content

Commit 7a9150f

Browse files
committed
Move toRdf tests into test_jsonld for now.
1 parent 7910dfe commit 7a9150f

2 files changed

Lines changed: 53 additions & 55 deletions

File tree

tests/test_jsonld.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,59 @@ def test_double_and_float_values(self):
720720
result = jsonld.to_rdf(input)
721721
assert result == expected
722722

723+
# Issue 204
724+
def test_conflicting_property_names(self):
725+
"""
726+
Conversion to RDF should allow a node in the root @context with
727+
a conflicting property name in its own @context
728+
"""
729+
input = {
730+
"@context": {
731+
"dublinCore": {
732+
"@id": "http://foo.bar/dc",
733+
"@context": {"title": "http://purl.org/dc/terms/title"},
734+
},
735+
"title": "http://foo.bar/title",
736+
},
737+
"@id": "http://foo.bar/obj/test",
738+
"title": "test",
739+
"dublinCore": {"title": "Chapter 1: Jonathan Harker's Journal"},
740+
}
741+
742+
expected = """<http://foo.bar/obj/test> <http://foo.bar/dc> _:b0 .
743+
<http://foo.bar/obj/test> <http://foo.bar/title> "test" .
744+
_:b0 <http://purl.org/dc/terms/title> "Chapter 1: Jonathan Harker's Journal" .
745+
"""
746+
747+
nquads = jsonld.to_rdf(input, options={'format': 'application/n-quads'})
748+
assert nquads == expected
749+
750+
751+
def test_conflicting_property_names_in_nested_node(self):
752+
"""
753+
Conversion to RDF should not ignore a @nest'ed node in the root @context
754+
a conflicting property name in its own @context
755+
"""
756+
input = {
757+
"@context": {
758+
"dublinCore": {
759+
"@id": "@nest",
760+
"@context": {"title": "http://purl.org/dc/terms/title"},
761+
},
762+
"title": "http://foo.bar/title",
763+
},
764+
"@id": "http://foo.bar/obj/test",
765+
"title": "test",
766+
"dublinCore": {"title": "Chapter 1: Jonathan Harker's Journal"},
767+
}
768+
769+
expected = """<http://foo.bar/obj/test> <http://foo.bar/title> "test" .
770+
<http://foo.bar/obj/test> <http://purl.org/dc/terms/title> "Chapter 1: Jonathan Harker's Journal" .
771+
"""
772+
773+
nquads = jsonld.to_rdf(input, options={'format': 'application/n-quads'})
774+
assert nquads == expected
775+
723776

724777
class TestCompact:
725778
# Issue 59 - PR: https://github.com/digitalbazaar/pyld/pull/60

tests/test_to_rdf.py

Lines changed: 0 additions & 55 deletions
This file was deleted.

0 commit comments

Comments
 (0)