def test_eventual_result_cancelled_on_exception(): mock_eventual_result = Mock(wait=Mock(side_effect=crochet.TimeoutError())) adapter = FidoFutureAdapter(mock_eventual_result) with pytest.raises(crochet.TimeoutError): adapter.result() assert mock_eventual_result.cancel.called is True
def test_eventual_result_cancelled_on_exception(): mock_eventual_result = Mock(wait=Mock(side_effect=crochet.TimeoutError())) adapter = FidoFutureAdapter(mock_eventual_result) with pytest.raises(fido.exceptions.HTTPTimeoutError) as exc_info: adapter.result(timeout=1) assert mock_eventual_result.cancel.called is True assert str(exc_info.value).startswith('Connection was closed by fido after blocking for timeout=1 seconds')
def test__compose_handles_timeout_error(self): request = MagicMock() pod = make_pod_with_hints() # Mock the RPC client. client = MagicMock() client.side_effect = crochet.TimeoutError() mock_getClient = self.patch(pods_module, "getClientFromIdentifiers") mock_getClient.return_value = succeed(client) form = ComposeMachineForm(data={}, request=request, pod=pod) self.assertTrue(form.is_valid()) error = self.assertRaises(PodProblem, form.compose) self.assertEquals( "Unable to compose a machine because '%s' driver timed out " "after 120 seconds." % pod.power_type, str(error))