def test_with_bad_ecl(self, valid_passport): missing = valid_passport.copy() missing.update({PassportFields.EYE_COLOR: "org"}) assert is_valid_passport(missing, True) is False for color in ["amb", "blu", "brn", "gry", "grn", "hzl", "oth"]: missing.update({PassportFields.EYE_COLOR: color}) assert is_valid_passport(missing, True) is True
def test_with_missing_data(self, valid_passport): for field in PassportFields: missing = valid_passport.copy() missing.pop(field, None) if field == PassportFields.COUNTRY_ID: assert is_valid_passport(missing) is True else: assert is_valid_passport(missing) is False
def test_with_bad_pid(self, valid_passport): missing = valid_passport.copy() missing.update({PassportFields.PASSPORT_ID: "12345678"}) assert is_valid_passport(missing, True) is False missing.update({PassportFields.PASSPORT_ID: "1234567890"}) assert is_valid_passport(missing, True) is False missing.update({PassportFields.PASSPORT_ID: "003467890"}) assert is_valid_passport(missing, True) is True
def test_with_bad_hcl(self, valid_passport): missing = valid_passport.copy() missing.update({PassportFields.HAIR_COLOR: "#abc"}) assert is_valid_passport(missing, True) is False missing.update({PassportFields.HAIR_COLOR: "#abcdefasdf"}) assert is_valid_passport(missing, True) is False missing.update({PassportFields.HAIR_COLOR: "#12345M"}) assert is_valid_passport(missing, True) is False
def test_with_bad_hgt(self, valid_passport): missing = valid_passport.copy() missing.update({PassportFields.HEIGHT: "149cm"}) assert is_valid_passport(missing, True) is False missing.update({PassportFields.HEIGHT: "194cm"}) assert is_valid_passport(missing, True) is False missing.update({PassportFields.HEIGHT: "58in"}) assert is_valid_passport(missing, True) is False missing.update({PassportFields.HEIGHT: "77in"}) assert is_valid_passport(missing, True) is False
def test_with_bad_iyr(self, valid_passport): missing = valid_passport.copy() missing.update({PassportFields.ISSUE_YEAR: 2009}) assert is_valid_passport(missing, True) is False missing.update({PassportFields.ISSUE_YEAR: 2021}) assert is_valid_passport(missing, True) is False
def test_with_bad_birth(self, valid_passport): missing = valid_passport.copy() missing.update({PassportFields.BIRTH_YEAR: 1919}) assert is_valid_passport(missing, True) is False missing.update({PassportFields.BIRTH_YEAR: 2003}) assert is_valid_passport(missing, True) is False
def test_with_strict_valid_passport(self, valid_passport): assert is_valid_passport(valid_passport, True) is True
def test_with_valid_passport(self, valid_passport): assert is_valid_passport(valid_passport) is True
def test_with_bad_eyr(self, valid_passport): missing = valid_passport.copy() missing.update({PassportFields.EXPIRATION_YEAR: 2019}) assert is_valid_passport(missing, True) is False missing.update({PassportFields.EXPIRATION_YEAR: 2031}) assert is_valid_passport(missing, True) is False