|
|
|
@ -15,6 +15,9 @@ class TestValidator(unittest.TestCase):
|
|
|
|
|
for name in testcfg.Validator_Invalid_Users_Chars_List:
|
|
|
|
|
self.assertFalse(self.validator.checkUsernameCharacters(name), name)
|
|
|
|
|
|
|
|
|
|
for name in testcfg.genRandomString():
|
|
|
|
|
self.assertFalse(self.validator.checkUsernameCharacters(name), name)
|
|
|
|
|
|
|
|
|
|
def test_check_username_length(self):
|
|
|
|
|
for name in testcfg.Validator_Valid_Users_Length:
|
|
|
|
|
self.assertTrue(self.validator.checkUsernameLength(name))
|
|
|
|
@ -25,20 +28,22 @@ class TestValidator(unittest.TestCase):
|
|
|
|
|
for name in testcfg.Validator_Valid_Mail:
|
|
|
|
|
self.assertTrue(self.validator.checkEmail(name))
|
|
|
|
|
for name in testcfg.Validator_Invalid_Mail:
|
|
|
|
|
self.assertFalse(self.validator.checkEmail(name), name)
|
|
|
|
|
|
|
|
|
|
for name in testcfg.genRandomString():
|
|
|
|
|
self.assertFalse(self.validator.checkEmail(name))
|
|
|
|
|
|
|
|
|
|
def test_check_user_exists(self):
|
|
|
|
|
self.assertTrue(self.validator.checkUserExists("root"))
|
|
|
|
|
self.assertTrue(self.validator.checkUserExists("nobody")) # remove in case there exists an actual system without
|
|
|
|
|
self.assertFalse(self.validator.checkUserExists("blsjdkfl"))
|
|
|
|
|
self.assertFalse(self.validator.checkUserExists("b90123ijk"))
|
|
|
|
|
self.assertFalse(self.validator.checkUserExists("curArrSosss"))
|
|
|
|
|
self.assertFalse(self.validator.checkUserExists("123WildPack123"))
|
|
|
|
|
# are there any more users which are assertable?
|
|
|
|
|
|
|
|
|
|
for User in testcfg.genRandomString():
|
|
|
|
|
self.assertFalse(self.validator.checkUserExists(User))
|
|
|
|
|
|
|
|
|
|
def test_check_user_in_db(self):
|
|
|
|
|
for name in testcfg.Validator_db_user_exists:
|
|
|
|
|
self.assertTrue(self.validator.checkUserInDB(name, testcfg.test_db))
|
|
|
|
|
|
|
|
|
|
for name in testcfg.Validator_db_user_inexistent:
|
|
|
|
|
self.assertFalse(self.validator.checkUserInDB(name, testcfg.test_db))
|
|
|
|
|
|
|
|
|
@ -51,12 +56,18 @@ class TestValidator(unittest.TestCase):
|
|
|
|
|
def test_check_datetime_format(self):
|
|
|
|
|
for cur in testcfg.Validator_valid_datetime:
|
|
|
|
|
self.assertTrue(self.validator.checkDatetimeFormat(cur))
|
|
|
|
|
for cur in testcfg.Validator_invalid_checkname_names:
|
|
|
|
|
self.assertFalse(self.validator.checkDatetimeFormat(cur))
|
|
|
|
|
for cur in testcfg.genRandomString():
|
|
|
|
|
self.assertFalse(self.validator.checkDatetimeFormat(cur))
|
|
|
|
|
|
|
|
|
|
def test_check_name(self):
|
|
|
|
|
for checkname in testcfg.Validator_valid_checkname_names:
|
|
|
|
|
self.assertTrue(self.validator.checkName(checkname))
|
|
|
|
|
for checkname in testcfg.Validator_invalid_checkname_names:
|
|
|
|
|
self.assertFalse(self.validator.checkName(checkname))
|
|
|
|
|
for name in testcfg.Validator_valid_checkname_names:
|
|
|
|
|
self.assertTrue(self.validator.checkName(name))
|
|
|
|
|
for name in testcfg.Validator_invalid_checkname_names:
|
|
|
|
|
self.assertFalse(self.validator.checkName(name))
|
|
|
|
|
for name in testcfg.genRandomString(alphabet="\n\b\r\t\f"):
|
|
|
|
|
self.assertFalse(self.validator.checkName(name))
|
|
|
|
|
|
|
|
|
|
def test_check_import_file(self):
|
|
|
|
|
self.assertTrue(self.validator.checkImportFile(testcfg.test_import_csv,
|
|
|
|
|