示例#1
0
 def testToRdfSmallInt(self):
     pred = "test-pred"
     obj = 20
     link = SimpleLink(pred=pred, obj=obj)
     bnode = BNode()
     graph = Graph()
     namespace = Namespace("test:")
     node_cache = NodeCache()
     link.to_rdf(subj=bnode,
                 namespace=namespace,
                 graph=graph,
                 node_cache=node_cache)
     results = graph.query("select ?s ?p ?o where {?s ?p ?o}")
     self.assertEqual(1, len(results))
     for result in results:
         _, _, o = result
         self.assertEqual(
             o.datatype, URIRef("http://www.w3.org/2001/XMLSchema#integer"))
示例#2
0
 def testToRdf(self):
     pred = "test-pred"
     obj = "test-obj"
     link = SimpleLink(pred=pred, obj=obj)
     bnode = BNode()
     graph = Graph()
     namespace = Namespace("test:")
     node_cache = NodeCache()
     link.to_rdf(subj=bnode,
                 namespace=namespace,
                 graph=graph,
                 node_cache=node_cache)
     results = graph.query("select ?s ?p ?o where {?s ?p ?o}")
     self.assertEqual(1, len(results))
     for result in results:
         s, p, o = result
         self.assertEqual(s, bnode)
         self.assertEqual(str(p), "test:test-pred")
         self.assertEqual(str(o), "test-obj")