def test_analyse_passport(): raw_passport = """ecl:gry pid:860033327 eyr:2020 hcl:#fffffd byr:1937 iyr:2017 cid:147 hgt:183cm""" first_passport = Passport(raw_passport) passport_fields = first_passport.analyse() assert len(passport_fields) == 8
def passport(): pprt = Passport() pprt.hcl = "#885577" pprt.ecl = "amb" pprt.byr = "1930" pprt.eyr = "2021" pprt.pid = "022111849" pprt.hgt = "182cm" pprt.iyr = "2013" pprt.cid = "244" return pprt
def test_ValidateHcl(self): testDict = {'hcl': '#123abc'} passportObj = Passport(testDict) self.assertTrue(passportObj.validateHcl()) testDict = {'hcl': '#123abz'} passportObj = Passport(testDict) self.assertFalse(passportObj.validateHcl()) testDict = {'hcl': '123abc'} passportObj = Passport(testDict) self.assertFalse(passportObj.validateHcl())
def test_ValidateEcl(self): testDict = {'ecl': 'brn'} passportObj = Passport(testDict) self.assertTrue(passportObj.validateEcl()) testDict = {'ecl': 'wat'} passportObj = Passport(testDict) self.assertFalse(passportObj.validateEcl())
def test_ValidateByr(self): testDict = {'byr': '2002'} passportObj = Passport(testDict) self.assertTrue(passportObj.validateByr()) testDict = {'byr': '2003'} passportObj = Passport(testDict) self.assertFalse(passportObj.validateByr())
def test_ValidatePid(self): testDict = {'pid': '000000001'} passportObj = Passport(testDict) self.assertTrue(passportObj.validatePid()) testDict = {'pid': '0123456789'} passportObj = Passport(testDict) self.assertFalse(passportObj.validatePid())
def test_valid_passport(): raw_passport = """ecl:gry pid:860033327 eyr:2020 hcl:#fffffd byr:1937 iyr:2017 cid:147 hgt:183cm""" first_passport = Passport(raw_passport) assert first_passport.is_valid()
def test_ValidateHgt(self): testDict = {'hgt': '60in'} passportObj = Passport(testDict) self.assertTrue(passportObj.validateHgt()) testDict = {'hgt': '190cm'} passportObj = Passport(testDict) self.assertTrue(passportObj.validateHgt()) testDict = {'hgt': '190in'} passportObj = Passport(testDict) self.assertFalse(passportObj.validateHgt()) testDict = {'hgt': '190'} passportObj = Passport(testDict) self.assertFalse(passportObj.validateHgt())