Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/tests/test_storage.py
Show First 20 Lines • Show All 3,968 Lines • ▼ Show 20 Lines | def test_generate_content_get_range_limit(self, swh_storage, swh_contents): | ||||
assert_contents_ok([contents_map[get_sha1s[-1]]], actual_contents2, ["sha1"]) | assert_contents_ok([contents_map[get_sha1s[-1]]], actual_contents2, ["sha1"]) | ||||
@pytest.mark.parametrize("limit", [1, 7, 10, 100, 1000]) | @pytest.mark.parametrize("limit", [1, 7, 10, 100, 1000]) | ||||
def test_origin_list(self, swh_storage, swh_origins, limit): | def test_origin_list(self, swh_storage, swh_origins, limit): | ||||
returned_origins = [] | returned_origins = [] | ||||
page_token = None | page_token = None | ||||
i = 0 | i = 0 | ||||
while True: | while True: | ||||
actual_page = swh_storage.origin_list(page_token=page_token, limit=limit) | actual_page = swh_storage.origin_list(page_token=page_token, limit=limit) | ||||
assert len(actual_page.results) <= limit | assert len(actual_page.results) <= limit | ||||
returned_origins.extend(actual_page.results) | returned_origins.extend(actual_page.results) | ||||
i += 1 | i += 1 | ||||
page_token = actual_page.next_page_token | page_token = actual_page.next_page_token | ||||
if page_token is None: | if page_token is None: | ||||
assert i * limit >= len(swh_origins) | assert i * limit >= len(swh_origins) | ||||
break | break | ||||
else: | else: | ||||
assert len(actual_page.results) == limit | assert len(actual_page.results) == limit | ||||
assert sorted(returned_origins) == sorted(swh_origins) | assert returned_origins == swh_origins | ||||
def test_origin_count(self, swh_storage, sample_data): | def test_origin_count(self, swh_storage, sample_data): | ||||
swh_storage.origin_add(sample_data.origins) | swh_storage.origin_add(sample_data.origins) | ||||
assert swh_storage.origin_count("github") == 3 | assert swh_storage.origin_count("github") == 3 | ||||
assert swh_storage.origin_count("gitlab") == 2 | assert swh_storage.origin_count("gitlab") == 2 | ||||
assert swh_storage.origin_count(".*user.*", regexp=True) == 5 | assert swh_storage.origin_count(".*user.*", regexp=True) == 5 | ||||
assert swh_storage.origin_count(".*user.*", regexp=False) == 0 | assert swh_storage.origin_count(".*user.*", regexp=False) == 0 | ||||
▲ Show 20 Lines • Show All 322 Lines • Show Last 20 Lines |