コード例 #1
0
ファイル: test.py プロジェクト: DrkCloudStrife/advent_of_code
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)
コード例 #2
0
 def test_valid_password_length(self):
     passObj = PasswordValidator("Wel@1234")
     self.assertTrue(passObj.check_length())
コード例 #3
0
 def test_invalid_password_length(self):
     passObj = PasswordValidator("abcd12")
     self.assertFalse(passObj.check_length())
コード例 #4
0
 def test_no_whitespace_character(self):
     passObj = PasswordValidator("Wel@1234")
     self.assertTrue(passObj.check_whitespace_character())
コード例 #5
0
 def test_atleast_one_whitespace_character(self):
     passObj = PasswordValidator("wel 12345")
     self.assertFalse(passObj.check_whitespace_character())
コード例 #6
0
 def test_atleast_one_special_character(self):
     passObj = PasswordValidator("Wel@1234")
     self.assertTrue(passObj.check_special_character())
コード例 #7
0
 def test_no_special_character(self):
     passObj = PasswordValidator("wel12345")
     self.assertFalse(passObj.check_special_character())
コード例 #8
0
 def test_no_alphanumeric_character(self):
     passObj = PasswordValidator("!@#$%^")
     self.assertFalse(passObj.check_alphanumeric())
コード例 #9
0
 def test_atleast_one_alphanumeric_character(self):
     passObj = PasswordValidator("Wel@1234")
     self.assertTrue(passObj.check_alphanumeric())
コード例 #10
0
 def test_no_uppercase_character(self):
     passObj = PasswordValidator("wel@1234")
     self.assertFalse(passObj.check_uppercase())
コード例 #11
0
 def test_atleast_one_uppercase_character(self):
     passObj = PasswordValidator("Wel@1234")
     self.assertTrue(passObj.check_uppercase())
コード例 #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)))