def test_Passport_checks_ecl(self): valid = ("amb", "blu", "brn", "gry", "grn", "hzl", "oth") invalid = ("bmb", "asdasd", "", "123") given = copy.deepcopy(formatted_input[0]) p = s.Passport(**given) for value in valid: p.ecl = value assert p.ecl == value for value in invalid: with pytest.raises(ValueError): p.ecl = value
def test_Passport_checks_hcl(self): valid_hcl = ("#123abc", "#623a2f", "#a97842", "#888785") invalid_hcl = ("#123abz", "123abc", "dab227", "74454a", "#123abcc") given = copy.deepcopy(formatted_input[0]) p = s.Passport(**given) for value in valid_hcl: p.hcl = value assert p.hcl == value for value in invalid_hcl: with pytest.raises(ValueError): p.hcl = value
def test_Passport_checks_hgt(self): valid_hgt = ("150cm", "193cm", "59in", "76in") invalid_hgt = ("149cm", "194cm", "58in", "77in", "22") given = copy.deepcopy(formatted_input[0]) p = s.Passport(**given) for value in valid_hgt: p.hgt = value assert p.hgt == value for value in invalid_hgt: with pytest.raises(ValueError): p.hgt = value
def test_Passport_checks_pid(self): valid = ("000000001", "087499704", "896056539", "545766238", "093154719") invalid = ("0123456789", "186cm", "02157", "3556412378") given = copy.deepcopy(formatted_input[0]) p = s.Passport(**given) for value in valid: p.pid = value assert p.pid == value for value in invalid: with pytest.raises(ValueError): p.pid = value
def test_Passport_checks_eyr(self): valid_eyr = ("2020", "2030") invalid_eyr = ("2019", "2031") given = copy.deepcopy(formatted_input[0]) given["eyr"] = valid_eyr[0] p = s.Passport(**given) assert p.eyr == valid_eyr[0] p.eyr = valid_eyr[1] assert p.eyr == valid_eyr[1] with pytest.raises(ValueError): p.eyr = invalid_eyr[0] with pytest.raises(ValueError): p.eyr = invalid_eyr[1]
def test_Passport_checks_byr(self): valid_byr = ("1920", "2002") invalid_byr = ("1919", "2003") given = copy.deepcopy(formatted_input[0]) given["byr"] = valid_byr[0] p = s.Passport(**given) assert p.byr in valid_byr p.byr = valid_byr[1] assert p.byr in valid_byr with pytest.raises(ValueError): p.byr = invalid_byr[0] with pytest.raises(ValueError): p.byr = invalid_byr[1]
def test_Passport_checks_iyr(self): valid_iyr = ("2010", "2020") invalid_iyr = ("2009", "2021") given = copy.deepcopy(formatted_input[0]) given["iyr"] = valid_iyr[0] p = s.Passport(**given) # assert valid_iyr[0] <= p.iyr <= valid_iyr[1] assert p.iyr == valid_iyr[0] p.iyr = valid_iyr[1] assert p.iyr == valid_iyr[1] with pytest.raises(ValueError): p.iyr = invalid_iyr[0] with pytest.raises(ValueError): p.iyr = invalid_iyr[1]
def test_Passport_handles_no_cid(self): given = copy.deepcopy(formatted_input[0]) del given["cid"] s.Passport(**given)