Changeset View
Changeset View
Standalone View
Standalone View
swh/search/tests/test_search.py
Show First 20 Lines • Show All 48 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['scroll_token'] is None | assert results['scroll_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_with_visit(self): | |||||
self.search.origin_update([ | |||||
{'url': 'http://foobar.baz', 'has_visits': True}, | |||||
]) | |||||
results = self.search.origin_search( | |||||
url_pattern='foobar', with_visit=True) | |||||
assert results == {'scroll_token': None, 'results': [ | |||||
{'url': 'http://foobar.baz'}]} | |||||
def test_origin_with_visit_added(self): | |||||
self.search.origin_update([ | |||||
{'url': 'http://foobar.baz'}, | |||||
]) | |||||
results = self.search.origin_search( | |||||
url_pattern='foobar', with_visit=True) | |||||
assert results == {'scroll_token': None, 'results': []} | |||||
self.search.origin_update([ | |||||
{'url': 'http://foobar.baz', 'has_visits': True}, | |||||
]) | |||||
results = self.search.origin_search( | |||||
url_pattern='foobar', with_visit=True) | |||||
assert results == {'scroll_token': None, 'results': [ | |||||
{'url': 'http://foobar.baz'}]} | |||||
def test_origin_intrinsic_metadata_description(self): | def test_origin_intrinsic_metadata_description(self): | ||||
self.search.origin_update([ | self.search.origin_update([ | ||||
{ | { | ||||
'url': 'http://origin1', | 'url': 'http://origin1', | ||||
'intrinsic_metadata': {}, | 'intrinsic_metadata': {}, | ||||
}, | }, | ||||
{ | { | ||||
'url': 'http://origin2', | 'url': 'http://origin2', | ||||
▲ Show 20 Lines • Show All 161 Lines • Show Last 20 Lines |