def test_should_respond_with_error_when_uncaught_exception_occurs(self): mock_request = Mock() mock_request.args.get.side_effect = ValueError('too fat to fly') response = validate_and_dispatch(mock_request, lambda x: None) self.assertEqual(response, ('Error : too fat to fly', 200))
def test_should_respond_with_error_when_uncaught_exception_occurs(self): mock_request = mock() mock_args = mock() mock_request.args = mock_args when(mock_args).get(any_value()).thenRaise(ValueError('too fat to fly')) response = validate_and_dispatch(mock_request, lambda x: None) self.assertEquals(response, ('Error : too fat to fly', 200))
def test_should_respond_with_error_when_uncaught_exception_occurs(self): mock_request = mock() mock_args = mock() mock_request.args = mock_args when(mock_args).get(any_value()).thenRaise( ValueError('too fat to fly')) response = validate_and_dispatch(mock_request, lambda x: None) self.assertEquals(response, ('Error : too fat to fly', 200))
def test_should_return_error_when_exception_is_raised(self): mock_request = mock() mock_args = {'q': 'foobar', 'handler': 'spam', 'key': 'bacon'} mock_request.args = mock_args concatenate_args = lambda query, dispatch_function, **kwargs: query + dispatch_function + kwargs[ 'key'] + kwargs['handler'] livestatus_service.webapp.dispatch_request = concatenate_args result = validate_and_dispatch(mock_request, 'noodles') self.assertEquals(result, 'foobarnoodlesbaconspam')
def test_should_return_error_when_exception_is_raised(self): mock_request = mock() mock_args = {'q': 'foobar', 'handler': 'spam', 'key': 'bacon'} mock_request.args = mock_args concatenate_args = lambda query, dispatch_function, **kwargs : query + dispatch_function + kwargs['key'] + kwargs['handler'] livestatus_service.webapp.dispatch_request = concatenate_args result = validate_and_dispatch(mock_request, 'noodles') self.assertEquals(result, 'foobarnoodlesbaconspam')
def test_should_return_error_when_exception_is_raised( self, dispatch_request): mock_request = Mock() mock_args = {'q': 'foobar', 'handler': 'spam', 'key': 'bacon'} mock_request.args = mock_args concatenate_args = ( lambda query, dispatch_function, **kwargs: query + dispatch_function + kwargs['key'] + kwargs['handler']) dispatch_request.side_effect = concatenate_args result = validate_and_dispatch(mock_request, 'noodles') self.assertEqual(result, 'foobarnoodlesbaconspam')
def test_should_return_error_when_exception_is_raised(self, dispatch_request): mock_request = Mock() mock_args = {'q': 'foobar', 'handler': 'spam', 'key': 'bacon'} mock_request.args = mock_args concatenate_args = (lambda query, dispatch_function, **kwargs: query + dispatch_function + kwargs['key'] + kwargs['handler']) dispatch_request.side_effect = concatenate_args result = validate_and_dispatch(mock_request, 'noodles') self.assertEqual(result, 'foobarnoodlesbaconspam')