def test_creator_redirection(fpath, lipsum_item): # ensure we can't add if not started c = Creator(fpath) with pytest.raises(RuntimeError, match="not started"): c.add_redirection("home", "hello", HOME_PATH) del c with Creator(fpath) as c: c.add_item(lipsum_item) c.add_redirection("home", "hello", HOME_PATH) c.add_redirection("accueil", "bonjour", HOME_PATH) zim = Archive(fpath) assert zim.entry_count == 3 assert zim.has_entry_by_path("home") is True assert zim.has_entry_by_path("accueil") is True assert zim.get_entry_by_path("home").is_redirect assert (zim.get_entry_by_path("home").get_redirect_entry().path == zim.get_entry_by_path(HOME_PATH).path) assert zim.get_entry_by_path("accueil").get_item().path == HOME_PATH assert "home" in list(zim.suggest("hello")) assert "accueil" in list(zim.suggest("bonjour"))
def test_reader_suggest_search( all_zims, filename, entry_count, suggestion_string, suggestion_count, suggestion_result, search_string, search_count, search_result, ): zim = Archive(all_zims / filename) # suggestion and search results assert zim.entry_count == entry_count assert (zim.get_estimated_suggestions_results_count(suggestion_string) == suggestion_count) assert list(zim.suggest(suggestion_string)) == suggestion_result assert zim.get_estimated_search_results_count( search_string) == search_count assert list(zim.search(search_string)) == search_result