Esempio n. 1
0
def _check_invalid_parameters(voicemail):
    invalid_parameters = []
    if voicemail.name is not None and not voicemail.name:
        invalid_parameters.append("name")
    if voicemail.number is not None and not validator.is_positive_number(voicemail.number):
        invalid_parameters.append("number")
    if voicemail.max_messages is not None and not validator.is_positive_number(voicemail.max_messages):
        invalid_parameters.append("max_messages")
    if voicemail.password is not None and not validator.is_positive_number(voicemail.password):
        invalid_parameters.append("password")
    if voicemail.attach_audio is not None and not isinstance(voicemail.attach_audio, bool):
        invalid_parameters.append("attach_audio")
    if voicemail.delete_messages is not None and not isinstance(voicemail.delete_messages, bool):
        invalid_parameters.append("delete_messages")
    if voicemail.ask_password is not None and not isinstance(voicemail.ask_password, bool):
        invalid_parameters.append("ask_password")
    if invalid_parameters:
        raise InvalidParametersError(invalid_parameters)
Esempio n. 2
0
    def test_is_positive_number(self):
        res = validator.is_positive_number("toto")
        assert_that(res, equal_to(False))

        res = validator.is_positive_number("-445")
        assert_that(res, equal_to(False))

        res = validator.is_positive_number(-445)
        assert_that(res, equal_to(False))

        res = validator.is_positive_number(35.4)
        assert_that(res, equal_to(False))

        res = validator.is_positive_number("0000")
        assert_that(res, equal_to(True))

        res = validator.is_positive_number("12345")
        assert_that(res, equal_to(True))

        res = validator.is_positive_number(1234)
        assert_that(res, equal_to(True))
Esempio n. 3
0
def _validate_number(field_name, value):
    if not validator.is_positive_number(value):
        raise errors.wrong_type(field_name, 'numeric string')