def test_early_validation_error_caught(self, container, interactor_function, error_result, error_handler, request_data, validators, teams, racers): error_instance = LogicError('foo') validators[0].side_effect = error_instance interactor = interactor_function( *validators)(add_team_member)(container) result = interactor(request_data) assert result == error_result validators[0].assert_called_once_with(request_data, racers=racers, teams=teams) validators[1].assert_not_called() error_handler.assert_called_once_with( error=error_instance, function_name= 'pca.application.tests.test_interactor.add_team_member', args=(request_data, ), kwargs={ 'teams': teams, 'racers': racers })
def test_late_validation_error_caught( self, container, interactor_function, error_result, error_handler, request_data, validators, teams, racers, ): error_instance = LogicError("foo") validators[1].side_effect = error_instance interactor = interactor_function( *validators)(add_team_member)(container) result = interactor(request_data) assert result == error_result validators[0].assert_called_once_with(request_data, racers=racers, teams=teams) validators[1].assert_called_once_with(request_data, racers=racers, teams=teams) error_handler.assert_called_once_with( error=error_instance, function_name= "pca.application.tests.test_interactor.add_team_member", args=(request_data, ), kwargs={ "teams": teams, "racers": racers }, )
def test_late_validation_error_caught(self, interactor, request_data, error_result, validators): error_instance = LogicError('foo') validators[1].side_effect = error_instance response = interactor(request_data) dependencies = get_attribute_dependencies(interactor) assert response == error_result validators[0].assert_called_once_with(request=request_data, dependencies=dependencies) validators[1].assert_called_once_with(request=request_data, dependencies=dependencies) interactor.error_handler.assert_called_once_with(error=error_instance, request=request_data)
def test_interactor_error_caught(self, container, interactor_function, error_handler, request_data, validators): error_instance = LogicError('foo') interactor_mock = mock.Mock(side_effect=error_instance) interactor = interactor_function( *validators)(interactor_mock)(container) interactor(request_data) validators[0].assert_called_once_with(request_data) validators[1].assert_called_once_with(request_data) interactor_mock.assert_called_once_with(request_data) error_handler.assert_called_once_with( error=error_instance, function_name= 'mock.mock.validated_by.<locals>.decorator.<locals>.decorated', args=(request_data, ), kwargs={})
class InvitingErrors(ErrorCatalog): INVITATION_EXPIRED = LogicError() EMAIL_TAKEN = LogicError()