Changeset View
Changeset View
Standalone View
Standalone View
swh/web/tests/common/test_origin_save.py
Show First 20 Lines • Show All 354 Lines • ▼ Show 20 Lines | |||||
def test__check_origin_exists_404(requests_mock): | def test__check_origin_exists_404(requests_mock): | ||||
url_ko = "https://example.org/some-inexistant-url" | url_ko = "https://example.org/some-inexistant-url" | ||||
requests_mock.head(url_ko, status_code=404) | requests_mock.head(url_ko, status_code=404) | ||||
with pytest.raises(BadInputExc, match="not exist"): | with pytest.raises(BadInputExc, match="not exist"): | ||||
_check_origin_exists(url_ko) | _check_origin_exists(url_ko) | ||||
@pytest.mark.parametrize("invalid_origin", [None, ""]) | |||||
def test__check_origin_invalid_input(invalid_origin): | |||||
with pytest.raises(BadInputExc, match="must be set"): | |||||
_check_origin_exists(invalid_origin) | |||||
def test__check_origin_exists_200(requests_mock): | def test__check_origin_exists_200(requests_mock): | ||||
url = "https://example.org/url" | url = "https://example.org/url" | ||||
requests_mock.head(url, status_code=200) | requests_mock.head(url, status_code=200) | ||||
# passes the check | # passes the check | ||||
actual_metadata = _check_origin_exists(url) | actual_metadata = _check_origin_exists(url) | ||||
# and we actually may have retrieved some metadata on the origin | # and we actually may have retrieved some metadata on the origin | ||||
▲ Show 20 Lines • Show All 224 Lines • Show Last 20 Lines |