예제 #1
0
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
예제 #2
0
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)
예제 #3
0
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))
예제 #4
0
def iter_search_entries_chunk_size_3(storage):
    return Search(storage).search_entries_page('entry',
                                               datetime(2010, 1, 1),
                                               chunk_size=3)
예제 #5
0
def search_entry_last(storage, feed, entry):
    Search(storage).search_entry_last('entry', (feed.url, entry.id))
예제 #6
0
def enable_and_update_search(storage):
    search = Search(storage)
    search.enable()
    search.update()
예제 #7
0
def search_entries_chunk_size_1(storage, _, __):
    list(
        Search(storage).search_entries_page('entry',
                                            datetime(2010, 1, 1),
                                            chunk_size=1))
예제 #8
0
def search_entry_counts(storage, _, __):
    Search(storage).search_entry_counts('entry')
예제 #9
0
def is_search_enabled(storage, _, __):
    Search(storage).is_enabled()
예제 #10
0
def update_search(storage, _, __):
    Search(storage).update()
예제 #11
0
def disable_search(storage, _, __):
    Search(storage).disable()
예제 #12
0
def enable_search(storage, _, __):
    Search(storage).enable()
예제 #13
0
 def strip_html(*args, **kwargs):
     barrier.wait()
     return Search.strip_html(*args, **kwargs)
예제 #14
0
 def strip_html(*args, **kwargs):
     in_strip_html.set()
     can_return_from_strip_html.wait()
     return Search.strip_html(*args, **kwargs)
예제 #15
0
 def strip_html(*args, **kwargs):
     nonlocal strip_html_called
     strip_html_called += 1
     return Search.strip_html(*args, **kwargs)