requests_mock = <requests_mock.mocker.Mocker object at 0x7fbee10f1b70>
mocker = <pytest_mock.plugin.MockerFixture object at 0x7fbee10f1d30>
mocked_time = None, origin_info = ('hg', 'mock://fake-origin-url/0')
def test_save_code_now_failure(requests_mock, mocker, mocked_time, origin_info):
"""Failed ingestion scenario should be reported"""
scenario = WebScenario()
visit_type, origin = origin_info
root_api_url = "mock://swh-web.example.org"
api_url = SaveCodeNowCheck.api_url_scn(root_api_url, origin, visit_type)
# creation request
scenario.add_step(
"post",
api_url,
fake_response(origin, visit_type, "accepted", "not yet scheduled"),
)
# status polling requests
scenario.add_step(
"get", api_url, [fake_response(origin, visit_type, "accepted", "scheduled")]
)
scenario.add_step(
"get", api_url, [fake_response(origin, visit_type, "accepted", "failed")]
)
scenario.install_mock(requests_mock)
# fmt: off
result = invoke(
[
"check-savecodenow", "--swh-web-url", root_api_url,
"origin", origin,
"--visit-type", visit_type,
],
catch_exceptions=True,
)
# fmt: on
> assert result.output == (
f"{SaveCodeNowCheck.TYPE} CRITICAL - {REPORT_MSG} {origin_info} took "
f"20.00s and failed.\n"
f"| 'total_time' = 20.00s\n"
)
E assert '' == "SAVECODENOW ...e' = 20.00s\n"
E - SAVECODENOW CRITICAL - Save code now request for origin ('hg', 'mock://fake-origin-url/0') took 20.00s and failed.
E - | 'total_time' = 20.00s
.tox/py3/lib/python3.7/site-packages/swh/icinga_plugins/tests/test_save_code_now.py:130: AssertionError
TEST RESULT
TEST RESULT
- Run At
- Jan 12 2022, 3:17 PM