self = <swh.search.tests.test_in_memory.InmemorySearchTest testMethod=test_sort_by_and_limit_query>
def test_sort_by_and_limit_query(self):
now = datetime.now(tz=timezone.utc).isoformat()
now_minus_5_hours = (
datetime.now(tz=timezone.utc) - timedelta(hours=5)
).isoformat()
now_plus_5_hours = (
datetime.now(tz=timezone.utc) + timedelta(hours=5)
).isoformat()
ORIGINS = [
{
"url": "http://foobar.1.com",
"nb_visits": 1,
"last_visit_date": now_minus_5_hours,
"last_eventful_visit_date": now_minus_5_hours,
},
{
"url": "http://foobar.2.com",
"nb_visits": 2,
"last_visit_date": now,
"last_eventful_visit_date": now,
},
{
"url": "http://foobar.3.com",
"nb_visits": 3,
"last_visit_date": now_plus_5_hours,
"last_eventful_visit_date": now_minus_5_hours,
},
]
self.search.origin_update(ORIGINS)
self.search.flush()
def _check_results(query, origin_indices):
page = self.search.origin_search(url_pattern="foobar", query=query)
results = [r["url"] for r in page.results]
assert results == [ORIGINS[index]["url"] for index in origin_indices]
> _check_results("sort_by = [-visits]", [2, 1, 0])
.tox/py3/lib/python3.7/site-packages/swh/search/tests/test_search.py:1208:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
query = 'sort_by = [-visits]', origin_indices = [2, 1, 0]
def _check_results(query, origin_indices):
page = self.search.origin_search(url_pattern="foobar", query=query)
results = [r["url"] for r in page.results]
> assert results == [ORIGINS[index]["url"] for index in origin_indices]
E AssertionError: assert ['http://foob...foobar.3.com'] == ['http://foob...foobar.1.com']
E At index 0 diff: 'http://foobar.1.com' != 'http://foobar.3.com'
E Full diff:
E - ['http://foobar.3.com', 'http://foobar.2.com', 'http://foobar.1.com']
E ? ^ ^
E + ['http://foobar.1.com', 'http://foobar.2.com', 'http://foobar.3.com']
E ? ^ ^
.tox/py3/lib/python3.7/site-packages/swh/search/tests/test_search.py:1206: AssertionError
TEST RESULT
TEST RESULT
- Run At
- Aug 4 2021, 4:50 PM