Changeset View
Changeset View
Standalone View
Standalone View
swh/web/tests/api/views/test_origin.py
Show All 10 Lines | |||||
from swh.model.model import Origin, OriginVisit, OriginVisitStatus | from swh.model.model import Origin, OriginVisit, OriginVisitStatus | ||||
from swh.storage.exc import StorageAPIError, StorageDBError | from swh.storage.exc import StorageAPIError, StorageDBError | ||||
from swh.storage.utils import now | from swh.storage.utils import now | ||||
from swh.web.api.utils import enrich_origin, enrich_origin_visit | from swh.web.api.utils import enrich_origin, enrich_origin_visit | ||||
from swh.web.common.exc import BadInputExc | from swh.web.common.exc import BadInputExc | ||||
from swh.web.common.origin_visits import get_origin_visits | from swh.web.common.origin_visits import get_origin_visits | ||||
from swh.web.common.utils import reverse | from swh.web.common.utils import reverse | ||||
from swh.web.tests.api.views import check_api_get_responses | |||||
from swh.web.tests.strategies import new_origin, new_snapshots, origin, visit_dates | from swh.web.tests.strategies import new_origin, new_snapshots, origin, visit_dates | ||||
from swh.web.tests.utils import check_api_get_responses | |||||
def _scroll_results(api_client, url): | def _scroll_results(api_client, url): | ||||
"""Iterates through pages of results, and returns them all.""" | """Iterates through pages of results, and returns them all.""" | ||||
results = [] | results = [] | ||||
while True: | while True: | ||||
rv = api_client.get(url) | rv = check_api_get_responses(api_client, url, status_code=200) | ||||
assert rv.status_code == 200, rv.data | |||||
assert rv["Content-Type"] == "application/json" | |||||
results.extend(rv.data) | results.extend(rv.data) | ||||
if "Link" in rv: | if "Link" in rv: | ||||
for link in parse_header_links(rv["Link"]): | for link in parse_header_links(rv["Link"]): | ||||
if link["rel"] == "next": | if link["rel"] == "next": | ||||
# Found link to next page of results | # Found link to next page of results | ||||
url = link["url"] | url = link["url"] | ||||
▲ Show 20 Lines • Show All 644 Lines • Show Last 20 Lines |