Beispiel #1
0
 def test_context_graph(self):
     ds = DataSet.get_dataset_from_graph(
         dataset_graph_uri=self.dataset_graph_uri,
         store=self.store
     )
     es_actions = []
     edm_record, es_action = tasks.synchronise_record(
         graph_uri="http://localhost:8000/resource/aggregation/ton-smits-huis/454/graph",
         ds=ds,
         store=self.store,
         es_actions=es_actions
     )
     context_graph, nr_levels = edm_record.get_context_graph(store=self.store, named_graph=edm_record.named_graph)
     self.assertIsNotNone(context_graph)
     self.assertIsInstance(context_graph, Graph)
     predicates = set(list(context_graph.predicates()))
     assert URIRef('http://www.openarchives.org/ore/terms/aggregates') in predicates
Beispiel #2
0
 def test_graph_indexing(self):
     ds = DataSet.get_dataset_from_graph(
         dataset_graph_uri=self.dataset_graph_uri,
         store=self.store
     )
     es_actions = []
     edm_record, es_action = tasks.synchronise_record(
         graph_uri="http://localhost:8000/resource/aggregation/ton-smits-huis/454/graph",
         ds=ds,
         store=self.store,
         es_actions=es_actions
     )
     self.assertTrue(
         edm_record.hub_id.endswith("ton-smits-huis_454")
     )
     action = edm_record.create_es_action(
         index=self.index_name,
         record_type="Aggregation",
         store=self.store,
         exclude_fields=['dc_rights']
     )
     self.assertIsNotNone(action)
     assert 'dc_rights' not in action['_source']
     assert action['_source']['system']['delving_recordType'] == "Aggregation"
     required_fields = [
         "_op_type", "_index", "_type", "_id", "_source"
     ]
     #  "graph", "slug", "delving_hubId", "delving_spec", "delving_recordType"
     assert set(list(es_action.keys())).issuperset(set(required_fields))
     assert 'about' in es_action['_source']
     assert 'edm_object' in es_action['_source']
     assert 'rdf' in es_action['_source']
     assert 'system' in es_action['_source']
     subjects = es_action['_source']['dc_subject']
     assert 'dc_rights' in es_action['_source']
     inline_id = 'http://data.cultureelerfgoed.nl/semnet/7403e26d-cf33-4372-ad72-a2f9fcf8f63b'
     inlined_example = [subject for subject in subjects if 'id' in subject and subject['id'] in [inline_id]][0]
     assert inlined_example
     assert inlined_example['id'] == inline_id
     assert inlined_example['value'] == "bomen"
     assert inlined_example['lang'] == "nl"
Beispiel #3
0
 def test_synchronise_record(self):
     ds = DataSet.get_dataset_from_graph(
         dataset_graph_uri=self.dataset_graph_uri,
         store=self.store
     )
     graph_list = tasks.get_out_of_sync_dataset_record_graph_uris(
         self.dataset_graph_uri,
         self.store
     )
     es_actions = []
     edm_record, es_action = tasks.synchronise_record(
         graph_uri=graph_list[0],
         ds=ds,
         store=self.store,
         es_actions=es_actions
     )
     self.assertIsNotNone(edm_record)
     self.assertIsNotNone(es_action)
     self.assertEqual(
         EDMRecord.objects.count(),
         1,
         "Only one record should be saved"
     )
     self.assertEquals(
         edm_record.dataset,
         ds
     )
     self.assertTrue(
         edm_record.hub_id.endswith("ton-smits-huis_454"),
     )
     self.assertRegex(
         edm_record.hub_id,
         "(.*?)_(.*?)_(.*?)"
     )
     assert edm_record.document_uri == 'http://localhost:8000/resource/aggregation/ton-smits-huis/454'
     self.assertEquals(
         edm_record.named_graph,
         URIRef('http://localhost:8000/resource/aggregation/ton-smits-huis/454/graph')
     )