ci: test with failing tests
Some checks failed
pull-requests-open / Check commit compliance (pull_request) Successful in 5s
pull-requests-open / Run tests (pull_request) Failing after 48s

This commit is contained in:
Bertrand Lanson 2024-09-14 21:16:00 +02:00
parent a0e45be691
commit 8bcc020346
Signed by: lanson
SSH Key Fingerprint: SHA256:/nqc6HGqld/PS208F6FUOvZlUzTS0rGpNNwR5O2bQBw

View File

@ -180,40 +180,6 @@ class TestPublicCloudConfigInfoModule(unittest.TestCase):
msg="Check mode: No changes made, would retrieve public cloud config.",
)
def test_network_timeout(self):
"""
Test behavior when a network timeout occurs.
"""
set_module_args(
{
"api_token": "mock_api_token",
"account_id": "mock_account_id",
}
)
with patch.object(AnsibleModule, "fail_json", side_effect=fail_json):
with pytest.raises(SystemExit) as e:
public_cloud_config_info.main()
# Simulate a network timeout error
mock_client_instance = MagicMock()
mock_client_instance.get.side_effect = Exception("Request timeout")
mock_client_class.return_value = mock_client_instance
# Mock AnsibleModule parameters
mock_module_instance = MagicMock()
mock_module_instance.params = {
"api_token": "mock_api_token",
"account_id": "mock_account_id",
}
mock_ansible_module.return_value = mock_module_instance
# Execute the run_module function
public_cloud_config_info.run_module()
# Assert fail_json is called with the timeout error message
mock_module_instance.fail_json.assert_called_once_with(msg="Request timeout")
@patch(
"ansible_collections.ednz_cloud.infomaniak.plugins.modules.public_cloud_config_info.InfomaniakAPIClient"
)
@ -241,7 +207,7 @@ class TestPublicCloudConfigInfoModule(unittest.TestCase):
captured_output = json.loads(e.value.args[0])
assert "msg" in captured_output
assert captured_output["msg"] == "Request timeout"
assert not captured_output["msg"] == "Request timeout"
mock_fail_json.assert_called_once()
@patch(