def test_when_validating_association_then_calls_common_and_association_validators( self, ): common = Mock(Validator) association = Mock(Validator) model = Mock() validator = ValidationAssociation(common=[common], association=[association]) validator.validate_association(model) common.validate.assert_called_once_with(model) association.validate.assert_called_once_with(model)
def test_when_validating_multiple_models_then_all_models_passed_to_validator( self): common = Mock(Validator) association = Mock(Validator) dissociation = Mock(Validator) model1 = Mock() model2 = Mock() validator = ValidationAssociation(common=[common], association=[association], dissociation=[dissociation]) validator.validate_association(model1, model2) validator.validate_dissociation(model1, model2) common.validate.assert_called_with(model1, model2) association.validate.assert_called_once_with(model1, model2) dissociation.validate.assert_called_once_with(model1, model2)