client = <django.test.client.Client object at 0x7fa004ef4b70>
mocker = <pytest_mock.plugin.MockerFixture object at 0x7fa004e7c160>
def test_accept_pending_save_request(client, mocker):
mock_scheduler = mocker.patch("swh.web.common.origin_save.scheduler")
visit_type = "git"
origin_url = "https://v2.pikacode.com/bthate/botlib.git"
save_request_url = reverse(
"api-1-save-origin",
url_args={"visit_type": visit_type, "origin_url": origin_url},
)
response = check_http_post_response(client, save_request_url, status_code=200)
assert response.data["save_request_status"] == SAVE_REQUEST_PENDING
accept_request_url = reverse(
"admin-origin-save-request-accept",
url_args={"visit_type": visit_type, "origin_url": origin_url},
)
check_not_login(client, accept_request_url)
tasks_data = [
{
"priority": "high",
"policy": "oneshot",
"type": "load-git",
"arguments": {"kwargs": {"repo_url": origin_url}, "args": []},
"status": "next_run_not_scheduled",
"id": 1,
}
]
mock_scheduler.create_tasks.return_value = tasks_data
mock_scheduler.get_tasks.return_value = tasks_data
client.login(username=_user_name, password=_user_password)
> response = check_http_post_response(client, accept_request_url, status_code=200)
.tox/py3/lib/python3.7/site-packages/swh/web/tests/admin/test_origin_save.py:156:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/py3/lib/python3.7/site-packages/swh/web/tests/utils.py:101: in check_http_post_response
content_type=content_type,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
response = <HttpResponse status_code=500, "text/html; charset=utf-8">
status_code = 200, content_type = '*/*'
def _assert_http_response(
response: HttpResponse, status_code: int, content_type: str
) -> HttpResponse:
if isinstance(response, Response):
drf_response = cast(Response, response)
error_context = (
drf_response.data.pop("traceback")
if isinstance(drf_response.data, dict) and "traceback" in drf_response.data
else drf_response.data
)
elif isinstance(response, StreamingHttpResponse):
error_context = getattr(response, "traceback", response.streaming_content)
else:
error_context = getattr(response, "traceback", response.content)
> assert response.status_code == status_code, error_context
E AssertionError: Traceback (most recent call last):
E File "/var/lib/jenkins/workspace/DWAPPS/tests-on-diff/.tox/py3/lib/python3.7/site-packages/django/core/handlers/base.py", line 113, in _get_response
E response = wrapped_callback(request, *callback_args, **callback_kwargs)
E File "/var/lib/jenkins/workspace/DWAPPS/tests-on-diff/.tox/py3/lib/python3.7/site-packages/django/views/decorators/http.py", line 40, in inner
E return func(request, *args, **kwargs)
E File "/var/lib/jenkins/workspace/DWAPPS/tests-on-diff/.tox/py3/lib/python3.7/site-packages/django/contrib/auth/decorators.py", line 21, in _wrapped_view
E return view_func(request, *args, **kwargs)
E File "/var/lib/jenkins/workspace/DWAPPS/tests-on-diff/.tox/py3/lib/python3.7/site-packages/swh/web/admin/origin_save.py", line 173, in _admin_origin_save_request_accept
E create_save_origin_request(visit_type, origin_url)
E File "/var/lib/jenkins/workspace/DWAPPS/tests-on-diff/.tox/py3/lib/python3.7/site-packages/swh/web/common/origin_save.py", line 523, in create_save_origin_request
E lister_id=lister.id, visit_type=visit_type, url=origin_url,
E File "<attrs generated init swh.scheduler.model.ListedOrigin>", line 14, in __init__
E __attr_validator_lister_id(self, __attr_lister_id, self.lister_id)
E File "/var/lib/jenkins/workspace/DWAPPS/tests-on-diff/.tox/py3/lib/python3.7/site-packages/attr/_make.py", line 2975, in __call__
E v(inst, attr, value)
E File "/var/lib/jenkins/workspace/DWAPPS/tests-on-diff/.tox/py3/lib/python3.7/site-packages/attrs_strict/_type_validation.py", line 105, in _validator
E _validate_elements(attribute, field, attribute.type)
E File "/var/lib/jenkins/workspace/DWAPPS/tests-on-diff/.tox/py3/lib/python3.7/site-packages/attrs_strict/_type_validation.py", line 131, in _validate_elements
E raise AttributeTypeError(value, attribute)
E attrs_strict._error.AttributeTypeError: lister_id must be <class 'uuid.UUID'> (got <MagicMock name='scheduler.get_or_create_lister().id' id='140325253554528'> that is a <class 'unittest.mock.MagicMock'>)
E
E assert 500 == 200
E +500
E -200
.tox/py3/lib/python3.7/site-packages/swh/web/tests/utils.py:34: AssertionError
TEST RESULT
TEST RESULT
- Run At
- Jun 11 2021, 4:14 PM