示例#1
0
def test_passport_scanner_validate_passport_with_invalid_passport_without_cid_returns_none(
):
    input = 'hcl:#cfa07d eyr:2025 pid:166559648 iyr:2011 ecl:brn hgt:59in'
    ps = PassportScanner()

    result = ps.validate_passport(passport=input)
    assert result == None
示例#2
0
def test_passport_scanner_validate_passport_with_invalid_passport_returns_none(
):
    input = 'iyr:2013 ecl:amb cid:350 eyr:2023 pid:028048884 hcl:#cfa07d byr:1929'
    ps = PassportScanner()

    result = ps.validate_passport(passport=input)
    assert result == None
示例#3
0
def test_passport_scanner_validate_passport_without_cid():
    input = 'hcl:#ae17e1 iyr:2013 eyr:2024 ecl:brn pid:760753108 byr:1931 hgt:179cm'
    expected_object = NorthPoleCredential(hcl='#ae17e1',
                                          iyr='2013',
                                          eyr='2024',
                                          ecl='brn',
                                          pid='760753108',
                                          byr='1931',
                                          hgt='179cm')

    ps = PassportScanner()

    result = ps.validate_passport(passport=input)
    assert result == expected_object
示例#4
0
def test_passport_scanner_validate_passport_without_newlines():
    input = 'ecl:gry pid:860033327 eyr:2020 hcl:#fffffd byr:1937 iyr:2017 cid:147 hgt:183cm'
    expected_object = NorthPoleCredential(ecl='gry',
                                          pid='860033327',
                                          eyr='2020',
                                          hcl='#fffffd',
                                          byr='1937',
                                          iyr='2017',
                                          cid='147',
                                          hgt='183cm')

    ps = PassportScanner()

    result = ps.validate_passport(passport=input)
    assert result == expected_object
示例#5
0
def test_passport_scanner_convert_to_dict_with_newlines():
    input = 'hcl:#ae17e1 iyr:2013\neyr:2024\necl:brn pid:760753108 byr:1931\nhgt:179cm'

    ps = PassportScanner()

    result = ps.convert_to_dict(input=input)
    assert result == {
        'hcl': '#ae17e1',
        'iyr': '2013',
        'eyr': '2024',
        'ecl': 'brn',
        'pid': '760753108',
        'byr': '1931',
        'hgt': '179cm'
    }
示例#6
0
def test_passport_scanner_convert_to_dict_without_newlines():
    input = 'ecl:gry pid:860033327 eyr:2020 hcl:#fffffd byr:1937 iyr:2017 cid:147 hgt:183cm'

    ps = PassportScanner()

    result = ps.convert_to_dict(input=input)
    assert result == {
        'ecl': 'gry',
        'pid': '860033327',
        'eyr': '2020',
        'hcl': '#fffffd',
        'byr': '1937',
        'iyr': '2017',
        'cid': '147',
        'hgt': '183cm'
    }
示例#7
0
def test_passport_scanner_validate_passport_with_additional_validation_returns_none(
        input):
    ps = PassportScanner()

    result = ps.validate_passport(passport=input)
    assert result == None