Exemple #1
0
def validate(model: Model) -> ApiErrors:
    api_errors = validate_generic(model)

    if api_errors.errors:
        return api_errors

    if isinstance(model, HasAddressMixin):
        api_errors = has_address_mixin.validate(model, api_errors)

    if isinstance(model, BankInformation):
        api_errors = bank_information.validate(model, api_errors)
    elif isinstance(model, Offer):
        api_errors = offer.validate(model, api_errors)
    elif isinstance(model, Offerer):
        api_errors = offerer.validate(model, api_errors)
    elif isinstance(model, Product):
        api_errors = product.validate(model, api_errors)
    elif isinstance(model, Stock):
        api_errors = stock.validate(model, api_errors)
    elif isinstance(model, User):
        api_errors = user.validate(model, api_errors)
    elif isinstance(model, VenueSQLEntity):
        api_errors = venue.validate(model, api_errors)

    return api_errors
Exemple #2
0
def test_should_return_error_message_when_siren_has_not_exactly_9_characters():
    # Given
    offerer = create_offerer(siren="1234")
    api_errors = ApiErrors()

    # When
    api_error = validate(offerer, api_errors)

    # Then
    assert api_error.errors["siren"] == ["Ce code SIREN est invalide"]
Exemple #3
0
def test_should_not_return_error_message_when_siren_has_exactly_9_characters():
    # Given
    offerer = create_offerer(siren="123456789")
    api_errors = ApiErrors()

    # When
    api_error = validate(offerer, api_errors)

    # Then
    assert api_error.errors == {}