Example #1
0
 def test_validate_name_not_string(self):
     """ Assumptions:
             - given name is not string (int instead)
     """
     name = 111
     with self.assertRaisesRegex(ServerNameNotValidError, "must be String"):
         ServerOp.validate_name(name)
Example #2
0
 def test_validate_name_too_long(self):
     """ Assumptions:
             - given name have 31 length
     """
     name = "a" * 31
     with self.assertRaisesRegex(ServerNameNotValidError, "wrong length"):
         ServerOp.validate_name(name)
Example #3
0
 def test_validate_name_positive(self):
     """ Assumptions:
             - given name is string with length >= 1 and <= 30
               and matched regex [A-Za-z0-9_]+
     """
     name = "aA09_"
     try:
         ServerOp.validate_name(name)
     except ServerNameNotValidError:
         self.fail("ServerNameNotValidError raised.")
Example #4
0
 def test_validate_name_wrong_characters(self):
     """ Assumptions:
             - given name does not match regex [A-Za-z0-9_]+
     """
     name_regex = r"[A-Za-z0-9_]+"
     wrong_chars = [
         char for char in list(string.printable)
         if not re.match(name_regex, char)
     ]
     for wrong_char in wrong_chars:
         with self.assertRaisesRegex(ServerNameNotValidError,
                                     "does not match regex"):
             ServerOp.validate_name(wrong_char)