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)
def test_valid_password_length(self): passObj = PasswordValidator("Wel@1234") self.assertTrue(passObj.check_length())
def test_invalid_password_length(self): passObj = PasswordValidator("abcd12") self.assertFalse(passObj.check_length())
def test_no_whitespace_character(self): passObj = PasswordValidator("Wel@1234") self.assertTrue(passObj.check_whitespace_character())
def test_atleast_one_whitespace_character(self): passObj = PasswordValidator("wel 12345") self.assertFalse(passObj.check_whitespace_character())
def test_atleast_one_special_character(self): passObj = PasswordValidator("Wel@1234") self.assertTrue(passObj.check_special_character())
def test_no_special_character(self): passObj = PasswordValidator("wel12345") self.assertFalse(passObj.check_special_character())
def test_no_alphanumeric_character(self): passObj = PasswordValidator("!@#$%^") self.assertFalse(passObj.check_alphanumeric())
def test_atleast_one_alphanumeric_character(self): passObj = PasswordValidator("Wel@1234") self.assertTrue(passObj.check_alphanumeric())
def test_no_uppercase_character(self): passObj = PasswordValidator("wel@1234") self.assertFalse(passObj.check_uppercase())
def test_atleast_one_uppercase_character(self): passObj = PasswordValidator("Wel@1234") self.assertTrue(passObj.check_uppercase())
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)))