Пример #1
0
    def test(self):
        hydra_adapter = HydraSchemaAdapter()
        self.schema_graph = hydra_adapter.update_schema_graph(
            self.schema_graph)
        print self.schema_graph.serialize(format="turtle")

        self.assertTrue(
            self.schema_graph.query("""ASK {
                ?c rdfs:subClassOf <http://www.w3.org/ns/hydra/core#Collection> ;
                   <http://www.w3.org/ns/hydra/core#supportedOperation> ?op .
            }"""))

        self.store = SPARQLDataStore(Graph(), schema_graph=self.schema_graph)
Пример #2
0
 def setUp(self):
     self.schema_graph = Graph().parse(join(dirname(__file__),
                                            "vocab.jsonld"),
                                       format="json-ld")
     print self.schema_graph.serialize(format="turtle")
     self.store = SPARQLDataStore(Graph(), schema_graph=self.schema_graph)
Пример #3
0
    "@context": {
        "hydra": "http://www.w3.org/ns/hydra/core#",
    },
    "@id": "urn:test:vocab:MyClass",
    "@type": "hydra:Class",
    "hydra:supportedProperty": [{
        "hydra:property": "urn:test:vocab:isWorking"
    }]
}
parse_graph_safely(schema_graph,
                   data=json.dumps(my_class_def),
                   format="json-ld")

context_file_path = path.join(path.dirname(__file__), "basic_context.jsonld")
context_iri = "/contexts/context.jsonld"

store = SPARQLDataStore(Graph(), schema_graph=schema_graph)
store.create_model("MyClass", context_iri, context_file_path=context_file_path)

client_manager = ClientResourceManager(store)
client_manager.import_store_models()
model = client_manager.get_model("MyClass")


class ContextUriTest(TestCase):
    def test_context_uri(self):
        obj = model.new(is_working=True)
        self.assertEquals(obj.context, context_iri)
        self.assertTrue(obj.is_working)
        print obj.to_rdf()