def test_validate_name_not_capital(self): """ Assumption: - given name have no capital letter at the beginning. """ name = "test" with self.assertRaisesRegex(ServerTypeNameNotValidError, "must start with capital"): ServerTypeOp.validate_name(name)
def test_validate_name_too_long(self): """ Assumptions: - given name have length == 21 """ name = "A" * 21 with self.assertRaisesRegex(ServerTypeNameNotValidError, "have wrong length"): ServerTypeOp.validate_name(name)
def test_validate_name_not_string(self): """ Assumptions: - given name is not a string """ name = 1111 with self.assertRaisesRegex(ServerTypeNameNotValidError, "must be String"): ServerTypeOp.validate_name(name)
def test_validate_name_capital(self): """ Assumption: - given name have capital letter at the beginning. """ name = "Test" try: ServerTypeOp.validate_name(name) except ServerTypeNameNotValidError: self.fail("ServerTypeNameNotValidError raised.")
def test_validate_name_incorrect_regex(self): """ Assumptions: - given name does not match respective regex """ wrong_names = ["A1", "Aa+", "A-", "A!@#$%^&_"] for wrong_name in wrong_names: with self.assertRaisesRegex(ServerTypeNameNotValidError, "does not match regex"): ServerTypeOp.validate_name(wrong_name)
def test_validate_name_correct_regex(self): """ Assumptions: - given correct name match regex. """ good_names = ["Test", "Test two"] for good_name in good_names: try: ServerTypeOp.validate_name(good_name) except ServerTypeNameNotValidError: self.fail("ServerTypeNameNotValidError raised.")
def test_validate_name_good_length(self): """ Assumptions: - given name have good length (border values) """ names = ["A", "A" * 20] for name in names: try: ServerTypeOp.validate_name(name) except ServerTypeNameNotValidError: self.fail("ServerTypeNameNotValidError raised.")