diff --git a/swh/icinga_plugins/tests/test_vault.py b/swh/icinga_plugins/tests/test_vault.py --- a/swh/icinga_plugins/tests/test_vault.py +++ b/swh/icinga_plugins/tests/test_vault.py @@ -10,33 +10,33 @@ from .web_scenario import WebScenario ROOT_URL = "mock://swh-web.example.org" +DIR_ID = "ab" * 20 -dir_id = "ab" * 20 response_pending = { - "obj_id": dir_id, + "obj_id": DIR_ID, "obj_type": "directory", "progress_message": "foo", "status": "pending", } response_done = { - "fetch_url": f"{ROOT_URL}/api/1/vault/directory/{dir_id}/raw/", + "fetch_url": f"{ROOT_URL}/api/1/vault/directory/{DIR_ID}/raw/", "id": 9, - "obj_id": dir_id, + "obj_id": DIR_ID, "obj_type": "directory", "status": "done", } response_failed = { - "obj_id": dir_id, + "obj_id": DIR_ID, "obj_type": "directory", "progress_message": "foobar", "status": "failed", } response_unknown_status = { - "obj_id": dir_id, + "obj_id": DIR_ID, "obj_type": "directory", "progress_message": "what", "status": "boo", @@ -48,20 +48,20 @@ pass def directory_get_random(self): - return bytes.fromhex(dir_id) + return bytes.fromhex(DIR_ID) def test_vault_immediate_success(requests_mock, mocker, mocked_time): scenario = WebScenario() - url = f"{ROOT_URL}/api/1/vault/directory/{dir_id}/" + url = f"{ROOT_URL}/api/1/vault/directory/{DIR_ID}/" scenario.add_step("get", url, {}, status_code=404) scenario.add_step("post", url, response_pending) scenario.add_step("get", url, response_done) scenario.add_step( "get", - f"{ROOT_URL}/api/1/vault/directory/{dir_id}/raw/", + f"{ROOT_URL}/api/1/vault/directory/{DIR_ID}/raw/", "this-is-a-tarball", headers={"Content-Type": "application/gzip", "Content-Length": "100000"}, ) @@ -83,7 +83,7 @@ ) assert result.output == ( - f"VAULT OK - cooking directory {dir_id} took " + f"VAULT OK - cooking directory {DIR_ID} took " f"10.00s and succeeded.\n" f"| 'total_time' = 10.00s\n" ) @@ -93,7 +93,7 @@ def test_vault_delayed_success(requests_mock, mocker, mocked_time): scenario = WebScenario() - url = f"{ROOT_URL}/api/1/vault/directory/{dir_id}/" + url = f"{ROOT_URL}/api/1/vault/directory/{DIR_ID}/" scenario.add_step("get", url, {}, status_code=404) scenario.add_step("post", url, response_pending) @@ -101,7 +101,7 @@ scenario.add_step("get", url, response_done) scenario.add_step( "get", - f"{ROOT_URL}/api/1/vault/directory/{dir_id}/raw/", + f"{ROOT_URL}/api/1/vault/directory/{DIR_ID}/raw/", "this-is-a-tarball", headers={"Content-Type": "application/gzip", "Content-Length": "100000"}, ) @@ -123,7 +123,7 @@ ) assert result.output == ( - f"VAULT OK - cooking directory {dir_id} took " + f"VAULT OK - cooking directory {DIR_ID} took " f"20.00s and succeeded.\n" f"| 'total_time' = 20.00s\n" ) @@ -133,7 +133,7 @@ def test_vault_failure(requests_mock, mocker, mocked_time): scenario = WebScenario() - url = f"{ROOT_URL}/api/1/vault/directory/{dir_id}/" + url = f"{ROOT_URL}/api/1/vault/directory/{DIR_ID}/" scenario.add_step("get", url, {}, status_code=404) scenario.add_step("post", url, response_pending) @@ -157,7 +157,7 @@ ) assert result.output == ( - f"VAULT CRITICAL - cooking directory {dir_id} took " + f"VAULT CRITICAL - cooking directory {DIR_ID} took " f"10.00s and failed with: foobar\n" f"| 'total_time' = 10.00s\n" ) @@ -167,7 +167,7 @@ def test_vault_unknown_status(requests_mock, mocker, mocked_time): scenario = WebScenario() - url = f"{ROOT_URL}/api/1/vault/directory/{dir_id}/" + url = f"{ROOT_URL}/api/1/vault/directory/{DIR_ID}/" scenario.add_step("get", url, {}, status_code=404) scenario.add_step("post", url, response_pending) @@ -191,7 +191,7 @@ ) assert result.output == ( - f"VAULT CRITICAL - cooking directory {dir_id} took " + f"VAULT CRITICAL - cooking directory {DIR_ID} took " f"10.00s and resulted in unknown status: boo\n" f"| 'total_time' = 10.00s\n" ) @@ -201,7 +201,7 @@ def test_vault_timeout(requests_mock, mocker, mocked_time): scenario = WebScenario() - url = f"{ROOT_URL}/api/1/vault/directory/{dir_id}/" + url = f"{ROOT_URL}/api/1/vault/directory/{DIR_ID}/" scenario.add_step("get", url, {}, status_code=404) scenario.add_step("post", url, response_pending) @@ -226,7 +226,7 @@ ) assert result.output == ( - f"VAULT CRITICAL - cooking directory {dir_id} took more than " + f"VAULT CRITICAL - cooking directory {DIR_ID} took more than " f"4020.00s and has status: foo\n" f"| 'total_time' = 4020.00s\n" ) @@ -238,7 +238,7 @@ test that vault_check requests another one.""" scenario = WebScenario() - url = f"{ROOT_URL}/api/1/vault/directory/{dir_id}/" + url = f"{ROOT_URL}/api/1/vault/directory/{DIR_ID}/" scenario.add_step("get", url, {}, status_code=200) scenario.add_step("get", url, {}, status_code=404) @@ -246,7 +246,7 @@ scenario.add_step("get", url, response_done) scenario.add_step( "get", - f"{ROOT_URL}/api/1/vault/directory/{dir_id}/raw/", + f"{ROOT_URL}/api/1/vault/directory/{DIR_ID}/raw/", "this-is-a-tarball", headers={"Content-Type": "application/gzip", "Content-Length": "100000"}, ) @@ -268,7 +268,7 @@ ) assert result.output == ( - f"VAULT OK - cooking directory {dir_id} took " + f"VAULT OK - cooking directory {DIR_ID} took " f"10.00s and succeeded.\n" f"| 'total_time' = 10.00s\n" )