示例#1
0
    def test_validate_name_too_long(self):
        """ Assumptions:
                - given name have 21 length
        """
        long_name = "T" * 21

        with self.assertRaisesRegex(AdminNameNotValidError, "wrong length"):
            AdminOp.validate_name(long_name)
示例#2
0
    def test_validate_name_wrong_type(self):
        """ Assumptions:
                - given name is not String (Integer instead)
        """
        wrong_type_name = 123

        with self.assertRaisesRegex(AdminNameNotValidError, "must be String"):
            AdminOp.validate_name(wrong_type_name)
示例#3
0
    def test_validate_name_too_short(self):
        """ Assumptions:
                - given name have 0 length
        """
        short_name = ""

        with self.assertRaisesRegex(AdminNameNotValidError, "wrong length"):
            AdminOp.validate_name(short_name)
示例#4
0
 def test_validate_name_positive(self):
     """ Assumptions:
             - given name met requirements
     """
     good_name = "Good Name"
     try:
         AdminOp.validate_name(good_name)
     except DbError:
         self.fail("Database error raised.")
示例#5
0
    def test_validate_name_wrong_characters(self):
        """ Assumptions:
                - given name contains incorrect characters
        """
        wrong_chars_names = ["(", ")", "_", "-", "*", "$"]

        for char in wrong_chars_names:
            with self.assertRaisesRegex(AdminNameNotValidError,
                                        "does not match regex"):
                AdminOp.validate_name(char)