feat/dns-zone-info #1
@ -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(
|
||||
|
Loading…
Reference in New Issue
Block a user