def test_invalid_search_query_error(storage, query, exc_type, call_method): # We're not testing this in test_reader_search.py because # the invalid query strings are search-provider-dependent. search = Search(storage) search.enable() with pytest.raises(exc_type) as excinfo: call_method(search, query) if isinstance(exc_type, tuple) and ActuallyOK in exc_type: return assert excinfo.value.message assert excinfo.value.__cause__ is None
def test_bs4_import_error(storage, monkeypatch): search = Search(storage) search.enable() monkeypatch.setattr('reader._search.bs4', None) monkeypatch.setattr('reader._search.bs4_import_error', ImportError('reason')) with pytest.raises(SearchError) as excinfo: search.update() assert 'search dependencies' in str(excinfo.value.message) assert isinstance(excinfo.value.__cause__, ImportError)
def test_minimum_sqlite_version(storage, monkeypatch): mock = MagicMock(wraps=require_version, side_effect=DBError('version')) monkeypatch.setattr('reader._search.require_version', mock) search = Search(storage) search.enable() with pytest.raises(SearchError) as excinfo: search.update() assert 'version' in excinfo.value.message mock.assert_called_with(ANY, (3, 18))
def iter_search_entries_chunk_size_3(storage): return Search(storage).search_entries_page('entry', datetime(2010, 1, 1), chunk_size=3)
def search_entry_last(storage, feed, entry): Search(storage).search_entry_last('entry', (feed.url, entry.id))
def enable_and_update_search(storage): search = Search(storage) search.enable() search.update()
def search_entries_chunk_size_1(storage, _, __): list( Search(storage).search_entries_page('entry', datetime(2010, 1, 1), chunk_size=1))
def search_entry_counts(storage, _, __): Search(storage).search_entry_counts('entry')
def is_search_enabled(storage, _, __): Search(storage).is_enabled()
def update_search(storage, _, __): Search(storage).update()
def disable_search(storage, _, __): Search(storage).disable()
def enable_search(storage, _, __): Search(storage).enable()
def strip_html(*args, **kwargs): barrier.wait() return Search.strip_html(*args, **kwargs)
def strip_html(*args, **kwargs): in_strip_html.set() can_return_from_strip_html.wait() return Search.strip_html(*args, **kwargs)
def strip_html(*args, **kwargs): nonlocal strip_html_called strip_html_called += 1 return Search.strip_html(*args, **kwargs)