Esempio n. 1
0
    def test_that_function_should_raise_exception_when_value_is_too_long(self):
        incorrect_values = 'a' * (MESSAGE_TASK_ID_MAX_LENGTH + 1)

        try:
            validate_id_value(incorrect_values, 'test')
        except ConcentValidationError as exception:
            self.assertEqual(exception.error_code,
                             ErrorCode.MESSAGE_VALUE_WRONG_LENGTH)
Esempio n. 2
0
    def test_that_function_should_raise_exception_when_value_is_blank(self):
        incorrect_values = ''

        try:
            validate_id_value(incorrect_values, 'test')
        except ConcentValidationError as exception:
            self.assertEqual(exception.error_code,
                             ErrorCode.MESSAGE_VALUE_BLANK)
Esempio n. 3
0
    def test_that_function_should_pass_when_value_is_allowed(self):
        correct_values = ['a', '0', 'a0', '0a', 'a-_b']

        for value in correct_values:
            try:
                validate_id_value(value, 'test')
            except Exception:  # pylint: disable=broad-except
                self.fail()
Esempio n. 4
0
    def test_that_function_should_raise_exception_when_value_is_not_a_string(
            self):
        incorrect_values = 1

        try:
            validate_id_value(incorrect_values, 'test')
        except ConcentValidationError as exception:
            self.assertEqual(exception.error_code,
                             ErrorCode.MESSAGE_VALUE_WRONG_TYPE)
Esempio n. 5
0
    def test_that_function_should_raise_exception_when_value_is_not_allowed(
            self):
        incorrect_values = [
            '*',
            'a()',
            '0@',
            'a+0',
            '0+a',
        ]

        for value in incorrect_values:
            try:
                validate_id_value(value, 'test')
            except ConcentValidationError as exception:
                self.assertEqual(exception.error_code,
                                 ErrorCode.MESSAGE_VALUE_NOT_ALLOWED)