Page MenuHomeSoftware Heritage

D5661.diff
No OneTemporary

D5661.diff

diff --git a/swh/web/common/origin_save.py b/swh/web/common/origin_save.py
--- a/swh/web/common/origin_save.py
+++ b/swh/web/common/origin_save.py
@@ -378,7 +378,6 @@
"""
_check_visit_type_savable(visit_type)
_check_origin_url_valid(origin_url)
- _check_origin_exists(origin_url)
# if all checks passed so far, we can try and save the origin
save_request_status = can_save_origin(origin_url, bypass_pending_review)
task = None
diff --git a/swh/web/tests/admin/test_origin_save.py b/swh/web/tests/admin/test_origin_save.py
--- a/swh/web/tests/admin/test_origin_save.py
+++ b/swh/web/tests/admin/test_origin_save.py
@@ -122,7 +122,6 @@
def test_accept_pending_save_request(client, mocker):
mock_scheduler = mocker.patch("swh.web.common.origin_save.scheduler")
- mock_origin_exists = mocker.patch("swh.web.common.origin_save._check_origin_exists")
visit_type = "git"
origin_url = "https://v2.pikacode.com/bthate/botlib.git"
save_request_url = reverse(
@@ -131,7 +130,6 @@
)
response = check_http_post_response(client, save_request_url, status_code=200)
assert response.data["save_request_status"] == SAVE_REQUEST_PENDING
- assert mock_origin_exists.called
accept_request_url = reverse(
"admin-origin-save-request-accept",
@@ -162,16 +160,11 @@
assert response.data[0]["save_task_status"] == SAVE_TASK_NOT_YET_SCHEDULED
-def test_reject_pending_save_request(client, mocker, requests_mock):
+def test_reject_pending_save_request(client, mocker):
mock_scheduler = mocker.patch("swh.web.common.origin_save.scheduler")
visit_type = "git"
origin_url = "https://wikipedia.com"
- # see swh.web.common.origin_save.origin_exists
- requests_mock.head(
- origin_url, status_code=200,
- )
-
save_request_url = reverse(
"api-1-save-origin",
url_args={"visit_type": visit_type, "origin_url": origin_url},
diff --git a/swh/web/tests/api/views/test_origin_save.py b/swh/web/tests/api/views/test_origin_save.py
--- a/swh/web/tests/api/views/test_origin_save.py
+++ b/swh/web/tests/api/views/test_origin_save.py
@@ -446,11 +446,6 @@
api_client, origin_to_review, requests_mock
):
- # see swh.web.common.origin_save.origin_exists
- requests_mock.head(
- origin_to_review, status_code=200,
- )
-
url = reverse(
"api-1-save-origin",
url_args={"visit_type": "git", "origin_url": origin_to_review},
@@ -472,11 +467,6 @@
oidc_profile = keycloak_oidc.login()
api_client.credentials(HTTP_AUTHORIZATION=f"Bearer {oidc_profile['refresh_token']}")
- # see swh.web.common.origin_save.origin_exists
- requests_mock.head(
- origin_to_review, status_code=200,
- )
-
check_created_save_request_status(
api_client,
mocker,
diff --git a/swh/web/tests/common/test_origin_save.py b/swh/web/tests/common/test_origin_save.py
--- a/swh/web/tests/common/test_origin_save.py
+++ b/swh/web/tests/common/test_origin_save.py
@@ -319,6 +319,22 @@
)
+def test__check_origin_exists_404(requests_mock):
+ url_ko = "https://example.org/some-inexistant-url"
+ requests_mock.head(url_ko, status_code=404)
+
+ with pytest.raises(BadInputExc, match="not exist"):
+ _check_origin_exists(url_ko)
+
+
+def test__check_origin_exists_200(requests_mock):
+ url = "https://example.org/url"
+ requests_mock.head(url, status_code=200)
+
+ # passes the check
+ _check_origin_exists(url)
+
+
def test_origin_exists_404(requests_mock):
"""Origin which does not exist should be reported as inexistent"""
url_ko = "https://example.org/some-inexistant-url"
@@ -329,9 +345,6 @@
origin_url=url_ko, exists=False, last_modified=None, content_length=None,
)
- with pytest.raises(BadInputExc, match="not exist"):
- _check_origin_exists(url_ko)
-
def test_origin_exists_200_no_data(requests_mock):
"""Existing origin should be reported as such (no extra information)"""
@@ -345,9 +358,6 @@
origin_url=url, exists=True, last_modified=None, content_length=None,
)
- # passes the check
- _check_origin_exists(url)
-
def test_origin_exists_200_with_data(requests_mock):
"""Existing origin should be reported as such (+ extra information)"""
@@ -369,9 +379,6 @@
last_modified="Sun, 21 Aug 2011 16:26:32 GMT",
)
- # passes the check
- _check_origin_exists(url)
-
@pytest.mark.django_db
@pytest.mark.parametrize("visit_status", ["created", "ongoing",])

File Metadata

Mime Type
text/plain
Expires
Thu, Jan 30, 11:07 AM (15 h, 28 m ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3219058

Event Timeline