Esempio n. 1
0
 def test_save_cached_resource(self):
     store = rdfstore._rdfstore_test
     store._clear_all()
     graph = load_nquad_fixtures()
     assert len(graph) > 0
     graph_store = store.get_graph_store
     resource = CacheResource()
     resource.source_uri = "http://nl.dbpedia.org/resource/Ton_Smits"
     resource.save()
     assert CacheResource.objects.count() == 1
     #  from ..tasks import store_cache_resource
     response = resource.update_cached_resource(graph_store)
     assert response
     resource_object = CacheResource.objects.first()
     assert resource_object.get_spec_name() == "cache"
     assert resource_object.named_graph == resource_object.document_uri + "#graph"
     assert resource_object.stored
     assert len(resource_object.get_graph()) > 0
     assert len(resource_object.source_rdf) > 0
Esempio n. 2
0
 def test_save_cached_resource(self):
     from search import get_es_client
     client = get_es_client()
     s = Search(client).index("test")
     del_response = client.delete_by_query(index='test', q="*:*")
     es_response = s.execute()
     self.assertEquals(
         es_response.hits.total,
         0
     )
     assert CacheResource.objects.count() == 0
     store = rdfstore._rdfstore_test
     store._clear_all()
     graph = load_nquad_fixtures()
     assert len(graph) > 0
     resource = CacheResource()
     resource.source_uri = "http://nl.dbpedia.org/resource/Ton_Smits"
     resource.save()
     response = tasks.store_cache_resource.delay(obj=resource, store=store)
     assert response.status
     assert response.result
     response = tasks.update_rdf_in_index.delay(obj=resource, store=store, index='test')
     time.sleep(1)
     assert response.status
     assert response.result
     assert CacheResource.objects.count() == 1
     es_response = s.execute()
     self.assertEquals(
         es_response.hits.total,
         1
     )
     record = es_response.hits[0]
     # assert len(list(record['_source'].keys())) > 2
     resource = CacheResource.objects.first()
     es_action =  resource.create_es_action(index="test", store=store, record_type="cached")
     assert es_action is not None
Esempio n. 3
0
 def setUpClass(cls):
     cls.store = rdfstore._rdfstore_test
     cls.store._clear_all()
     cls.graph = load_nquad_fixtures()
     cls.dataset_graph_uri = "http://localhost:8000/resource/dataset/ton-smits-huis/graph"
     cls.about_uri = "http://localhost:8000/resource/aggregation/ton-smits-huis/454"