Пример #1
0
    def test_update_with_empty_and_search(
        self,
        monkeypatch: MonkeyPatch,
        match_item_generator_registry: MatchItemGeneratorRegistry,
        index_builder: IndexBuilder,
        index_searcher: IndexSearcher,
    ) -> None:
        """
        Test if things can also be deleted from the index during an update
        """

        def empty_match_item_gen():
            yield from ()

        index_builder.build_full_index()

        monkeypatch.setattr(
            match_item_generator_registry["change_dependent"],
            "generate_match_items",
            empty_match_item_gen,
        )

        index_builder.build_changed_sub_indices("some_change_dependent_whatever")
        assert list(index_searcher.search("**")) == [
            ("Localization-dependent", [SearchResult(title="localization_dependent", url="")]),
        ]
Пример #2
0
 def test_update_and_search_no_update(
     self,
     index_builder: IndexBuilder,
     index_searcher: IndexSearcher,
 ) -> None:
     index_builder._mark_index_as_built()
     index_builder.build_changed_sub_indices("something")
     assert not list(index_searcher.search("**"))
Пример #3
0
 def test_update_and_search_with_update(
     self,
     index_builder: IndexBuilder,
     index_searcher: IndexSearcher,
 ) -> None:
     index_builder._mark_index_as_built()
     index_builder.build_changed_sub_indices("some_change_dependent_whatever")
     assert list(index_searcher.search("**")) == [
         ("Change-dependent", [SearchResult(title="change_dependent", url="")]),
     ]
Пример #4
0
 def test_update_only_not_built(
     self,
     index_builder: IndexBuilder,
 ) -> None:
     index_builder.build_changed_sub_indices("something")
     assert not index_builder.index_is_built(index_builder._redis_client)