def test_store_remote_cached_resource(self): test_uri = "http://nl.dbpedia.org/resource/Ton_Smits" resource = CacheResource.get_remote_lod_resource(test_uri) store = rdfstore._rdfstore_test assert len(resource) > 0 store._clear_all() graph_store = store.get_graph_store cache_graph = "http://{}/resource/cache#graph".format(RDFRecord.get_rdf_base_url()) self.assertFalse( store.ask( query="where {{<{}> ?p ?o}}".format(test_uri) )) response = CacheResource.store_remote_cached_resource(resource, graph_store, cache_graph) assert response is not None assert response self.assertTrue( store.ask( query="where {{<{}> ?p ?o}}".format(test_uri) ) ) # cacheUrl is no longer being added self.assertFalse( store.ask( query="where {{<{}> <http://schemas.delving.org/nave/terms/cacheUrl> ?o}}".format( test_uri) ) )
def test_get_remote_lod_resource(self): test_uri = "http://sws.geonames.org/2759794" resource = CacheResource.get_remote_lod_resource(test_uri) assert resource is not None assert isinstance(resource, Graph) assert len(list(resource.predicates())) != 0 assert len(list(resource.objects(predicate=RDF.type))) == 2
def test_bad_get_remote_lod_resource(self): bad_uri = "http://sws.geonames.org/2759794/about2.rdf" resource = CacheResource.get_remote_lod_resource(bad_uri) assert resource is None