diff options
author | Amade Nemes <nemesamade@gmail.com> | 2021-03-08 14:09:54 +0100 |
---|---|---|
committer | Amade Nemes <nemesamade@gmail.com> | 2021-03-08 14:09:54 +0100 |
commit | 843be477c77ea91e07eeaff12ed46e031e310b1e (patch) | |
tree | e9601360390817f847961c92ef01c101b2e5e1ba | |
parent | 16b218ba20fca55ebd2d1e1ba923a0c3f50c6c36 (diff) | |
download | rdflib-843be477c77ea91e07eeaff12ed46e031e310b1e.tar.gz |
Added tests for testing correct behaviour of compute_qname for URNs, and relatedly for correct turtle serialization of URNs
-rw-r--r-- | test/test_namespace.py | 11 | ||||
-rw-r--r-- | test/test_turtle_serialize.py | 12 |
2 files changed, 21 insertions, 2 deletions
diff --git a/test/test_namespace.py b/test/test_namespace.py index 2a8a1e65..5c73d223 100644 --- a/test/test_namespace.py +++ b/test/test_namespace.py @@ -31,6 +31,15 @@ class NamespacePrefixTest(unittest.TestCase): g.compute_qname(URIRef("http://foo/bar/")), ("ns1", URIRef("http://foo/bar/"), ""), ) + # should compute qnames of URNs correctly as well + self.assertEqual( + g.compute_qname(URIRef("urn:ISSN:0167-6423")), + ("ns5", URIRef("urn:ISSN:"), "0167-6423"), + ) + self.assertEqual( + g.compute_qname(URIRef("urn:ISSN:")), + ("ns5", URIRef("urn:ISSN:"), ""), + ) def test_reset(self): data = ( @@ -123,4 +132,4 @@ class NamespacePrefixTest(unittest.TestCase): self.assertFalse(ref in RDFS, "ClosedNamespace(RDFS) includes out-of-ns member rdfs:example") ref = URIRef('http://www.w3.org/1999/02/22-rdf-syntax-ns#type') - self.assertTrue(ref in RDF, "_RDFNamespace does not include rdf:type")
\ No newline at end of file + self.assertTrue(ref in RDF, "_RDFNamespace does not include rdf:type") diff --git a/test/test_turtle_serialize.py b/test/test_turtle_serialize.py index 9c073e8c..3725bcd0 100644 --- a/test/test_turtle_serialize.py +++ b/test/test_turtle_serialize.py @@ -1,4 +1,4 @@ -from rdflib import Graph, URIRef, BNode, RDF, Literal, Namespace +from rdflib import Graph, URIRef, BNode, RDF, RDFS, Literal, Namespace from rdflib.collection import Collection from rdflib.plugins.serializers.turtle import TurtleSerializer @@ -80,6 +80,7 @@ def test_turtle_namespace(): graph.bind("GENO", "http://purl.obolibrary.org/obo/GENO_") graph.bind("RO", "http://purl.obolibrary.org/obo/RO_") graph.bind("RO_has_phenotype", "http://purl.obolibrary.org/obo/RO_0002200") + graph.bind("SERIAL", "urn:ISSN:") graph.add( ( URIRef("http://example.org"), @@ -87,6 +88,14 @@ def test_turtle_namespace(): URIRef("http://purl.obolibrary.org/obo/GENO_0000385"), ) ) + graph.add( + ( + URIRef("urn:ISSN:0167-6423"), + RDFS.label, + Literal("Science of Computer Programming"), + + ) + ) output = [ val for val in graph.serialize(format="turtle").splitlines() @@ -95,6 +104,7 @@ def test_turtle_namespace(): output = " ".join(output) assert "RO_has_phenotype:" in output assert "GENO:0000385" in output + assert "SERIAL:0167-6423" in output if __name__ == "__main__": |