Exemplo n.º 1
0
 def _update_in_supplements_with_neighbour_creation(
         self, lemma_to_update: Lemma, lemma_dict: LemmaDict,
         remove_items: UpdaterRemoveList):
     lemma_to_update.update_lemma_dict(lemma_dict, remove_items)
     if lemma_to_update:
         idx = self._register.get_index_of_lemma(lemma_to_update)
         if idx:
             if idx > 0:
                 self._u_i_s_w_n_c_1(idx, lemma_dict, lemma_to_update)
             with contextlib.suppress(IndexError):
                 idx = self._register.get_index_of_lemma(lemma_to_update)
                 if idx:
                     self._u_i_s_w_n_c_2(idx, lemma_dict, lemma_to_update)
Exemplo n.º 2
0
 def test_set_lemma_dict(self):
     update_basic_dict = copy.deepcopy(self.basic_dict)
     update_lemma = Lemma(update_basic_dict, self.volumes["I,1"],
                          self.authors)
     update_dict = {
         "lemma":
         "lemma2",
         "previous":
         "previous1",
         "next":
         "next",
         "chapters": [{
             "start": 1,
             "end": 3,
             "author": "Abel"
         }, {
             "start": 3,
             "end": 3,
             "author": "Abbott"
         }]
     }
     remove_item = ["redirect", "some_bla"]
     update_lemma.update_lemma_dict(update_dict)
     compare("lemma2", update_lemma["lemma"])
     compare("lemma002", update_lemma.sort_key)
     compare("previous1", update_lemma["previous"])
     compare("next", update_lemma["next"])
     self.assertTrue(update_lemma["redirect"])
     compare([{
         "start": 1,
         "end": 3,
         "author": "Abel"
     }, {
         "start": 3,
         "end": 3,
         "author": "Abbott"
     }], update_lemma.lemma_dict["chapters"])
     update_lemma.update_lemma_dict(update_dict, remove_items=remove_item)
     compare("lemma2", update_lemma["lemma"])
     compare("previous1", update_lemma["previous"])
     compare("next", update_lemma["next"])
     self.assertIsNone(update_lemma["redirect"])
     compare([{
         "start": 1,
         "end": 3,
         "author": "Abel"
     }, {
         "start": 3,
         "end": 3,
         "author": "Abbott"
     }], update_lemma.lemma_dict["chapters"])