def test_check_if_ip_can_be_resolved_ip_connect_to_mount_target_unknown_error( mocker): ip_mock = mocker.patch("socket.create_connection", side_effect=[socket.error]) with pytest.raises(mount_efs.FallbackException) as excinfo: mount_efs.mount_target_ip_address_can_be_resolved(FALLBACK_IP_ADDRESS) assert "Unknown error" in str(excinfo) utils.assert_called_n_times(ip_mock, 1)
def test_check_if_ip_can_be_resolved_ip_connect_to_mount_target_timeout( mocker): ip_mock = mocker.patch( 'socket.create_connection', side_effect=[socket.timeout, socket.timeout, socket.timeout]) with pytest.raises(mount_efs.FallbackException) as excinfo: mount_efs.mount_target_ip_address_can_be_resolved(FALLBACK_IP_ADDRESS) assert 'timeout' in str(excinfo) utils.assert_called_n_times(ip_mock, 3)
def test_check_if_ip_can_be_resolved_ip_connect_to_mount_target_timeout_first_time( mocker): ip_mock = mocker.patch('socket.create_connection', side_effect=[ socket.timeout, socket.socket(socket.AF_INET, socket.SOCK_STREAM) ]) assert True == mount_efs.mount_target_ip_address_can_be_resolved( FALLBACK_IP_ADDRESS) utils.assert_called_n_times(ip_mock, 2)
def test_check_if_ip_can_be_resolved_ip_resolve_succeed(mocker): ip_mock = mocker.patch("socket.create_connection") assert True == mount_efs.mount_target_ip_address_can_be_resolved( FALLBACK_IP_ADDRESS) utils.assert_called(ip_mock)