Changeset View
Changeset View
Standalone View
Standalone View
swh/search/tests/test_search.py
Show First 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | def test_origin_url_unique_word_prefix_multiple_results(self): | ||||
results = self.search.origin_search(url_pattern='qux') | results = self.search.origin_search(url_pattern='qux') | ||||
assert results['next_page_token'] is None | assert results['next_page_token'] is None | ||||
results = [res['url'] for res in results['results']] | results = [res['url'] for res in results['results']] | ||||
expected_results = ['http://barbaz.qux', 'http://qux.quux'] | expected_results = ['http://barbaz.qux', 'http://qux.quux'] | ||||
assert sorted(results) == sorted(expected_results) | assert sorted(results) == sorted(expected_results) | ||||
def test_origin_url_all_terms(self): | |||||
self.search.origin_update([ | |||||
{'url': 'http://foo.bar/baz'}, | |||||
{'url': 'http://foo.bar/foo.bar'}, | |||||
]) | |||||
self.search.flush() | |||||
# Only results containing all terms should be returned. | |||||
results = self.search.origin_search(url_pattern='foo bar baz') | |||||
assert results == {'next_page_token': None, 'results': [ | |||||
{'url': 'http://foo.bar/baz'}, | |||||
]} | |||||
def test_origin_with_visit(self): | def test_origin_with_visit(self): | ||||
self.search.origin_update([ | self.search.origin_update([ | ||||
{'url': 'http://foobar.baz', 'has_visits': True}, | {'url': 'http://foobar.baz', 'has_visits': True}, | ||||
]) | ]) | ||||
self.search.flush() | self.search.flush() | ||||
results = self.search.origin_search( | results = self.search.origin_search( | ||||
url_pattern='foobar', with_visit=True) | url_pattern='foobar', with_visit=True) | ||||
▲ Show 20 Lines • Show All 196 Lines • Show Last 20 Lines |