1515 create_indexcard ,
1616 update_indexcard_content ,
1717 create_supplement ,
18+ index_indexcards ,
1819)
1920
2021from ._with_real_services import RealElasticTestCase
@@ -30,7 +31,7 @@ def setUp(self):
3031 def test_for_smoke_without_daemon (self ):
3132 _indexcard = self ._create_indexcard (
3233 focus_iri = BLARG .hello ,
33- rdf_tripledict = { BLARG . hello : { RDFS .label : {rdf .literal ('hello' )} }},
34+ rdf_twopledict = { RDFS .label : {rdf .literal ('hello' )}},
3435 )
3536 _messages_chunk = messages .MessagesChunk (
3637 messages .MessageType .UPDATE_INDEXCARD ,
@@ -44,7 +45,7 @@ def test_for_smoke_without_daemon(self):
4445 def test_for_smoke_with_daemon (self ):
4546 _indexcard = self ._create_indexcard (
4647 focus_iri = BLARG .hello ,
47- rdf_tripledict = { BLARG . hello : { RDFS .label : {rdf .literal ('hello' )} }},
48+ rdf_twopledict = { RDFS .label : {rdf .literal ('hello' )}},
4849 )
4950 _messages_chunk = messages .MessagesChunk (
5051 messages .MessageType .UPDATE_INDEXCARD ,
@@ -78,11 +79,9 @@ def test_cardsearch_after_deletion(self):
7879 def test_cardsearch_after_updates (self ):
7980 _cards = self ._fill_test_data_for_querying ()
8081 self ._update_indexcard_content (_cards [BLARG .c ], BLARG .c , {
81- BLARG .c : {
82- RDF .type : {BLARG .Thing },
83- DCTERMS .subject : {BLARG .subj_ac , BLARG .subj_c }, # subj_bc removed; subj_c added
84- DCTERMS .title : {rdf .literal ('cccc' )},
85- },
82+ RDF .type : {BLARG .Thing },
83+ DCTERMS .subject : {BLARG .subj_ac , BLARG .subj_c }, # subj_bc removed; subj_c added
84+ DCTERMS .title : {rdf .literal ('cccc' )},
8685 })
8786 self ._index_indexcards ([_cards [BLARG .c ]])
8887 _cases = [
@@ -112,11 +111,9 @@ def test_cardsearch_pagination(self):
112111 _focus_iri = BLARG [f'i{ _i } ' ]
113112 _expected_iris .add (_focus_iri )
114113 _cards .append (self ._create_indexcard (_focus_iri , {
115- _focus_iri : {
116- RDF .type : {BLARG .Thing },
117- DCTERMS .title : {rdf .literal (f'card #{ _i } ' )},
118- DCTERMS .created : {rdf .literal (_start_date + timedelta (weeks = _i , days = _i ))},
119- },
114+ RDF .type : {BLARG .Thing },
115+ DCTERMS .title : {rdf .literal (f'card #{ _i } ' )},
116+ DCTERMS .created : {rdf .literal (_start_date + timedelta (weeks = _i , days = _i ))},
120117 }))
121118 self ._index_indexcards (_cards )
122119 # gather all pages results:
@@ -187,12 +184,10 @@ def test_valuesearch_after_deletion(self):
187184 def test_valuesearch_after_updates (self ):
188185 _cards = self ._fill_test_data_for_querying ()
189186 self ._update_indexcard_content (_cards [BLARG .c ], BLARG .c , {
190- BLARG .c : {
191- RDF .type : {BLARG .Thing },
192- DCTERMS .creator : {BLARG .someone_new }, # someone_else removed; someone_new added
193- DCTERMS .subject : {BLARG .subj_ac , BLARG .subj_c , BLARG .subj_new }, # subj_bc removed; subj_new added
194- DCTERMS .title : {rdf .literal ('cccc' )},
195- },
187+ RDF .type : {BLARG .Thing },
188+ DCTERMS .creator : {BLARG .someone_new }, # someone_else removed; someone_new added
189+ DCTERMS .subject : {BLARG .subj_ac , BLARG .subj_c , BLARG .subj_new }, # subj_bc removed; subj_new added
190+ DCTERMS .title : {rdf .literal ('cccc' )},
196191 })
197192 self ._index_indexcards ([_cards [BLARG .c ]])
198193 _cases = [
@@ -239,16 +234,15 @@ def _assert_valuesearch_values(self, queryparams, expected_values):
239234
240235 def _fill_test_data_for_querying (self ):
241236 _card_a = self ._create_indexcard (BLARG .a , {
242- BLARG .a : {
243- RDF .type : {BLARG .Thing },
244- OWL .sameAs : {BLARG .a_same , BLARG .a_same2 },
245- DCTERMS .created : {rdf .literal (date (1999 , 12 , 31 ))},
246- DCTERMS .creator : {BLARG .someone },
247- DCTERMS .title : {rdf .literal ('aaaa' )},
248- DCTERMS .subject : {BLARG .subj_ac , BLARG .subj_a },
249- DCTERMS .references : {BLARG .b , BLARG .c },
250- DCTERMS .description : {rdf .literal ('This place is not a place of honor... no highly esteemed deed is commemorated here... nothing valued is here.' , language = 'en' )},
251- },
237+ RDF .type : {BLARG .Thing },
238+ OWL .sameAs : {BLARG .a_same , BLARG .a_same2 },
239+ DCTERMS .created : {rdf .literal (date (1999 , 12 , 31 ))},
240+ DCTERMS .creator : {BLARG .someone },
241+ DCTERMS .title : {rdf .literal ('aaaa' )},
242+ DCTERMS .subject : {BLARG .subj_ac , BLARG .subj_a },
243+ DCTERMS .references : {BLARG .b , BLARG .c },
244+ DCTERMS .description : {rdf .literal ('This place is not a place of honor... no highly esteemed deed is commemorated here... nothing valued is here.' , language = 'en' )},
245+ }, rdf_tripledict = {
252246 BLARG .someone : {
253247 FOAF .name : {rdf .literal ('some one' )},
254248 },
@@ -265,16 +259,15 @@ def _fill_test_data_for_querying(self):
265259 },
266260 })
267261 _card_b = self ._create_indexcard (BLARG .b , {
268- BLARG .b : {
269- RDF .type : {BLARG .Thing },
270- OWL .sameAs : {BLARG .b_same },
271- DCTERMS .created : {rdf .literal (date (2012 , 12 , 31 ))},
272- DCTERMS .creator : {BLARG .someone },
273- DCTERMS .title : {rdf .literal ('bbbb' )},
274- DCTERMS .subject : {BLARG .subj_b , BLARG .subj_bc },
275- DCTERMS .references : {BLARG .c },
276- DCTERMS .description : {rdf .literal ('What is here was dangerous and repulsive to us. This message is a warning about danger. ' , language = 'en' )},
277- },
262+ RDF .type : {BLARG .Thing },
263+ OWL .sameAs : {BLARG .b_same },
264+ DCTERMS .created : {rdf .literal (date (2012 , 12 , 31 ))},
265+ DCTERMS .creator : {BLARG .someone },
266+ DCTERMS .title : {rdf .literal ('bbbb' )},
267+ DCTERMS .subject : {BLARG .subj_b , BLARG .subj_bc },
268+ DCTERMS .references : {BLARG .c },
269+ DCTERMS .description : {rdf .literal ('What is here was dangerous and repulsive to us. This message is a warning about danger. ' , language = 'en' )},
270+ }, rdf_tripledict = {
278271 BLARG .someone : {
279272 FOAF .name : {rdf .literal ('some one' )},
280273 },
@@ -285,44 +278,37 @@ def _fill_test_data_for_querying(self):
285278 },
286279 })
287280 _card_c = self ._create_indexcard (BLARG .c , {
288- BLARG .c : {
289- RDF .type : {BLARG .Thing },
290- DCTERMS .created : {rdf .literal (date (2024 , 12 , 31 ))},
291- DCTERMS .creator : {BLARG .someone_else },
292- DCTERMS .title : {rdf .literal ('cccc' )},
293- DCTERMS .subject : {
294- BLARG ['subj_ac/' ], # this one has an extra trailing slash
295- BLARG .subj_bc ,
296- BLARG .subj_c ,
297- },
298- DCTERMS .description : {rdf .literal ('The danger is unleashed only if you substantially disturb this place physically. This place is best shunned and left uninhabited.' , language = 'en' )},
281+ RDF .type : {BLARG .Thing },
282+ DCTERMS .created : {rdf .literal (date (2024 , 12 , 31 ))},
283+ DCTERMS .creator : {BLARG .someone_else },
284+ DCTERMS .title : {rdf .literal ('cccc' )},
285+ DCTERMS .subject : {
286+ BLARG ['subj_ac/' ], # this one has an extra trailing slash
287+ BLARG .subj_bc ,
288+ BLARG .subj_c ,
299289 },
290+ DCTERMS .description : {rdf .literal ('The danger is unleashed only if you substantially disturb this place physically. This place is best shunned and left uninhabited.' , language = 'en' )},
291+ }, rdf_tripledict = {
300292 BLARG .someone_else : {
301293 FOAF .name : {rdf .literal ('some one else' )},
302294 },
303295 })
304296 create_supplement (_card_a , BLARG .a , {
305- BLARG .a : {
306- DCTERMS .replaces : {BLARG .a_past },
307- DCAT .servesDataset : {
308- rdf .blanknode ({DCAT .spatialResolutionInMeters : {rdf .literal (10 )}}),
309- },
297+ DCTERMS .replaces : {BLARG .a_past },
298+ DCAT .servesDataset : {
299+ rdf .blanknode ({DCAT .spatialResolutionInMeters : {rdf .literal (10 )}}),
310300 },
311301 })
312302 create_supplement (_card_b , BLARG .b , {
313- BLARG .b : {
314- DCTERMS .replaces : {BLARG .b_past },
315- DCAT .servesDataset : {
316- rdf .blanknode ({DCAT .spatialResolutionInMeters : {rdf .literal (7 )}}),
317- },
303+ DCTERMS .replaces : {BLARG .b_past },
304+ DCAT .servesDataset : {
305+ rdf .blanknode ({DCAT .spatialResolutionInMeters : {rdf .literal (7 )}}),
318306 },
319307 })
320308 create_supplement (_card_c , BLARG .c , {
321- BLARG .c : {
322- DCTERMS .replaces : {BLARG .c_past },
323- DCAT .servesDataset : {
324- rdf .blanknode ({DCAT .spatialResolutionInMeters : {rdf .literal (333 )}}),
325- },
309+ DCTERMS .replaces : {BLARG .c_past },
310+ DCAT .servesDataset : {
311+ rdf .blanknode ({DCAT .spatialResolutionInMeters : {rdf .literal (333 )}}),
326312 },
327313 })
328314 _cards = {
@@ -608,30 +594,28 @@ def valuesearch_sameas_cases(self):
608594 {BLARG .subj_ac , BLARG .subj_a , BLARG .subj_c , BLARG .subj_bc },
609595 )
610596
611- def _create_indexcard (self , focus_iri : str , rdf_tripledict : rdf .RdfTripleDictionary ) -> trove_db .Indexcard :
612- _indexcard = create_indexcard (focus_iri , rdf_tripledict , (TROVE ['derive/osfmap_json' ],))
597+ def _create_indexcard (
598+ self ,
599+ focus_iri : str ,
600+ rdf_twopledict : rdf .RdfTwopleDictionary | None = None ,
601+ rdf_tripledict : rdf .RdfTripleDictionary | None = None ,
602+ ) -> trove_db .Indexcard :
603+ _indexcard = create_indexcard (focus_iri , rdf_twopledict , rdf_tripledict , (TROVE ['derive/osfmap_json' ],))
613604 self ._indexcard_focus_by_uuid [str (_indexcard .uuid )] = focus_iri
614605 return _indexcard
615606
616607 def _update_indexcard_content (
617608 self ,
618609 indexcard : trove_db .Indexcard ,
619610 focus_iri : str ,
620- rdf_tripledict : rdf .RdfTripleDictionary ,
611+ rdf_twopledict : rdf .RdfTwopleDictionary | None = None ,
612+ rdf_tripledict : rdf .RdfTripleDictionary | None = None ,
621613 ) -> None :
622- update_indexcard_content (indexcard , focus_iri , rdf_tripledict )
614+ update_indexcard_content (indexcard , focus_iri , rdf_twopledict , rdf_tripledict )
623615 self ._indexcard_focus_by_uuid [str (indexcard .uuid )] = focus_iri
624616
625617 def _index_indexcards (self , indexcards : Iterable [trove_db .Indexcard ]):
626- _messages_chunk = messages .MessagesChunk (
627- messages .MessageType .UPDATE_INDEXCARD ,
628- [_indexcard .id for _indexcard in indexcards ],
629- )
630- self .assertTrue (all (
631- _response .is_done
632- for _response in self .index_strategy .pls_handle_messages_chunk (_messages_chunk )
633- ))
634- self .index_strategy .pls_refresh ()
618+ index_indexcards (self .index_strategy , indexcards )
635619
636620 def _delete_indexcards (self , indexcards : Iterable [trove_db .Indexcard ]):
637621 for _indexcard in indexcards :
0 commit comments