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)
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)
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()
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)
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)