Page MenuHomeSoftware Heritage

Jenkins > .tox.py3.lib.python3.7.site-packages.swh.web.tests.api.views.test_origin_save::Tests / Python tests / test_create_save_request_only_when_needed
Failed

TEST RESULT

Run At
Jun 11 2021, 4:14 PM
Details
api_client = <rest_framework.test.APIClient object at 0x7fa004a98828> mocker = <pytest_mock.plugin.MockerFixture object at 0x7fa004a987f0> def test_create_save_request_only_when_needed(api_client, mocker): origin_url = "https://github.com/webpack/webpack" SaveOriginRequest.objects.create( visit_type="git", origin_url=origin_url, status=SAVE_REQUEST_ACCEPTED, loading_task_id=56, ) check_created_save_request_status( api_client, mocker, origin_url, scheduler_task_status="next_run_not_scheduled", expected_request_status=SAVE_REQUEST_ACCEPTED, expected_task_status=SAVE_TASK_NOT_YET_SCHEDULED, ) sors = list( SaveOriginRequest.objects.filter(visit_type="git", origin_url=origin_url) ) assert len(sors) == 1 check_created_save_request_status( api_client, mocker, origin_url, scheduler_task_status="next_run_scheduled", scheduler_task_run_status="scheduled", expected_request_status=SAVE_REQUEST_ACCEPTED, expected_task_status=SAVE_TASK_SCHEDULED, ) sors = list( SaveOriginRequest.objects.filter(visit_type="git", origin_url=origin_url) ) assert len(sors) == 1 visit_date = datetime.now(tz=timezone.utc) + timedelta(hours=1) check_created_save_request_status( api_client, mocker, origin_url, scheduler_task_status="completed", expected_request_status=SAVE_REQUEST_ACCEPTED, expected_task_status=SAVE_TASK_NOT_YET_SCHEDULED, > visit_date=visit_date, ) .tox/py3/lib/python3.7/site-packages/swh/web/tests/api/views/test_origin_save.py:355: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ .tox/py3/lib/python3.7/site-packages/swh/web/tests/api/views/test_origin_save.py:136: in check_created_save_request_status response = check_api_post_responses(api_client, url, data=None, status_code=200) .tox/py3/lib/python3.7/site-packages/swh/web/tests/utils.py:181: in check_api_post_responses api_client, url, status_code, content_type="application/json", data=data .tox/py3/lib/python3.7/site-packages/swh/web/tests/utils.py:158: in check_api_post_response content_type=content_type, _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ response = <Response status_code=500, "application/json">, status_code = 200 content_type = 'application/json' 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/rest_framework/views.py", line 506, in dispatch E response = handler(request, *args, **kwargs) E File "/var/lib/jenkins/workspace/DWAPPS/tests-on-diff/.tox/py3/lib/python3.7/site-packages/rest_framework/decorators.py", line 50, in handler E return func(*args, **kwargs) E File "/var/lib/jenkins/workspace/DWAPPS/tests-on-diff/.tox/py3/lib/python3.7/site-packages/swh/web/api/apiurls.py", line 96, in api_view_f E response = f(request, **kwargs) E File "/var/lib/jenkins/workspace/DWAPPS/tests-on-diff/.tox/py3/lib/python3.7/site-packages/swh/web/api/apidoc.py", line 348, in documented_view E raise exc E File "/var/lib/jenkins/workspace/DWAPPS/tests-on-diff/.tox/py3/lib/python3.7/site-packages/swh/web/api/apidoc.py", line 345, in documented_view E return {"data": f(request, **kwargs), "doc_data": doc_data} E File "/var/lib/jenkins/workspace/DWAPPS/tests-on-diff/.tox/py3/lib/python3.7/site-packages/swh/web/api/views/origin_save.py", line 93, in api_save_origin E **data, 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='140325249113504'> 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