Changeset View
Changeset View
Standalone View
Standalone View
swh/search/tests/test_search.py
Show First 20 Lines • Show All 206 Lines • ▼ Show 20 Lines | def test_origin_nb_visit_update_search(self): | ||||
_check_nb_visit(5) | _check_nb_visit(5) | ||||
_update_nb_visit(3) | _update_nb_visit(3) | ||||
_check_nb_visit(5) # nb_visit shouldn't get updated and remain remain 5 | _check_nb_visit(5) # nb_visit shouldn't get updated and remain remain 5 | ||||
with pytest.raises(AssertionError): | with pytest.raises(AssertionError): | ||||
_check_nb_visit(3) | _check_nb_visit(3) | ||||
def test_origin_last_visit_date_update_search(self): | |||||
origin_url = "http://foobar.baz" | |||||
self.search.origin_update([{"url": origin_url}]) | |||||
self.search.flush() | |||||
def _update_last_visit_date(last_visit_date): | |||||
self.search.origin_update( | |||||
[{"url": origin_url, "last_visit_date": last_visit_date}] | |||||
) | |||||
self.search.flush() | |||||
def _check_last_visit_date(last_visit_date): | |||||
actual_page = self.search.origin_search( | |||||
url_pattern=origin_url, last_visit_date=last_visit_date, | |||||
) | |||||
assert actual_page.next_page_token is None | |||||
results = [r["url"] for r in actual_page.results] | |||||
expected_results = [origin_url] | |||||
assert sorted(results) == sorted(expected_results) | |||||
_update_last_visit_date("2021-06-09T10:47:20.069684+00:00") | |||||
_check_last_visit_date("2021-06-09T10:47:20.069684+00:00") | |||||
_update_last_visit_date("2015-06-09T10:47:20.069684+00:00") | |||||
_check_last_visit_date("2021-06-09T10:47:20.069684+00:00") | |||||
with pytest.raises(AssertionError): | |||||
vlorentz: It's hard to spot the difference. Could you make the date constants and comment that the… | |||||
_check_last_visit_date("2015-06-09T10:47:20.069684+00:00") | |||||
def test_origin_update_with_no_visit_types(self): | def test_origin_update_with_no_visit_types(self): | ||||
""" | """ | ||||
Update an origin with visit types first then with no visit types, | Update an origin with visit types first then with no visit types, | ||||
check origin can still be searched with visit types afterwards. | check origin can still be searched with visit types afterwards. | ||||
""" | """ | ||||
origin_url = "http://foobar.baz" | origin_url = "http://foobar.baz" | ||||
self.search.origin_update([{"url": origin_url, "visit_types": ["git"]}]) | self.search.origin_update([{"url": origin_url, "visit_types": ["git"]}]) | ||||
self.search.flush() | self.search.flush() | ||||
▲ Show 20 Lines • Show All 422 Lines • Show Last 20 Lines |
It's hard to spot the difference. Could you make the date constants and comment that the difference is the years?