Ejemplo n.º 1
0
import os
from main import PasswordValidator

path = os.path.dirname(os.path.realpath(__file__))
path_1 = open("{dir}/{file}".format(dir=path, file="../../../spec/fixtures/2020_04_sample.txt"))
validator = PasswordValidator(path_1)

print("Passport validity match?")
validator.validate_pt1()
print(len(validator.valid_passports) == 2)

print("Part 2 validity match?")
path_2 = open("{dir}/{file}".format(dir=path, file="../../../spec/fixtures/2020_04_pt2_sample.txt"))
validator2 = PasswordValidator(path_2)
validator2.validate_pt2()
print(len(validator2.valid_passports) == 4)
Ejemplo n.º 2
0
 def test_valid_password_length(self):
     passObj = PasswordValidator("Wel@1234")
     self.assertTrue(passObj.check_length())
Ejemplo n.º 3
0
 def test_invalid_password_length(self):
     passObj = PasswordValidator("abcd12")
     self.assertFalse(passObj.check_length())
Ejemplo n.º 4
0
 def test_no_whitespace_character(self):
     passObj = PasswordValidator("Wel@1234")
     self.assertTrue(passObj.check_whitespace_character())
Ejemplo n.º 5
0
 def test_atleast_one_whitespace_character(self):
     passObj = PasswordValidator("wel 12345")
     self.assertFalse(passObj.check_whitespace_character())
Ejemplo n.º 6
0
 def test_atleast_one_special_character(self):
     passObj = PasswordValidator("Wel@1234")
     self.assertTrue(passObj.check_special_character())
Ejemplo n.º 7
0
 def test_no_special_character(self):
     passObj = PasswordValidator("wel12345")
     self.assertFalse(passObj.check_special_character())
Ejemplo n.º 8
0
 def test_no_alphanumeric_character(self):
     passObj = PasswordValidator("!@#$%^")
     self.assertFalse(passObj.check_alphanumeric())
Ejemplo n.º 9
0
 def test_atleast_one_alphanumeric_character(self):
     passObj = PasswordValidator("Wel@1234")
     self.assertTrue(passObj.check_alphanumeric())
Ejemplo n.º 10
0
 def test_no_uppercase_character(self):
     passObj = PasswordValidator("wel@1234")
     self.assertFalse(passObj.check_uppercase())
Ejemplo n.º 11
0
 def test_atleast_one_uppercase_character(self):
     passObj = PasswordValidator("Wel@1234")
     self.assertTrue(passObj.check_uppercase())
Ejemplo n.º 12
0
import os
import main
from main import PasswordValidator

path = os.path.dirname(os.path.realpath(__file__))
path = open("{dir}/{file}".format(dir=path, file="../../shared/input_day02.txt"))

validator = PasswordValidator(path)
validator.validate_pt1()
print("Part 1 | Valid Passwords: {}".format(len(validator.valid_passwords)))

validator.validate_pt2()
print("Part 2 | Valid Passwords: {}".format(len(validator.valid_passwords)))