def test_read_file(self):
        """
        test first line of file matches what we expect
        """
        input = Day4.read_file("input")

        self.assertEqual("ecl:gry pid:860033327 eyr:2020 hcl:#fffffd\n",
                         input[0])
    def test_has_two_valid_passports(self):
        """
        testing to see if there are 2 valid passports in the data

        byr (Birth Year)
    iyr (Issue Year)
    eyr (Expiration Year)
    hgt (Height)
    hcl (Hair Color)
    ecl (Eye Color)
    pid (Passport ID)
    cid (Country ID)
        :return:
        """
        lines = Day4.read_file("input")
        count = Day4.count_valid_passports(lines)

        self.assertEqual(2, count)
Example #3
0
def test_parse():
    d = Day4()
    input_1 = "[1518-11-01 00:25] wakes up"
    r = (datetime(year=1518, month=11, day=1, hour=0, minute=25), 'w')
    assert r == d.parse_input(input=input_1)
    input_2 = "[1518-11-01 00:05] falls asleep"
    r = (datetime(year=1518, month=11, day=1, hour=0, minute=5), 'f')
    assert r == d.parse_input(input=input_2)
    input_3 = "[1518-11-01 23:58] Guard #99 begins shift"
    r = (datetime(year=1518, month=11, day=1, hour=23, minute=58), '99')
    assert r == d.parse_input(input=input_3)
Example #4
0
def test_part2():
    d = Day4()
    input_1 = """[1518-11-01 00:00] Guard #10 begins shift
[1518-11-01 00:05] falls asleep
[1518-11-01 00:25] wakes up
[1518-11-01 00:30] falls asleep
[1518-11-01 00:55] wakes up
[1518-11-01 23:58] Guard #99 begins shift
[1518-11-02 00:40] falls asleep
[1518-11-02 00:50] wakes up
[1518-11-03 00:05] Guard #10 begins shift
[1518-11-03 00:24] falls asleep
[1518-11-03 00:29] wakes up
[1518-11-04 00:02] Guard #99 begins shift
[1518-11-04 00:36] falls asleep
[1518-11-04 00:46] wakes up
[1518-11-05 00:03] Guard #99 begins shift
[1518-11-05 00:45] falls asleep
[1518-11-05 00:55] wakes up"""
    assert ('99', 45, 4455) == d.part2(input_1)
Example #5
0
def tpuzzle2():
    return Day4(testCase2)
Example #6
0
def tpuzzle():
    return Day4(testCase)
 def test_find_n_for_key_abcdef(self):
     input = 'abcdef'
     expected = 609043
     actual = Day4.find_n_for_key(input, 5)
     self.assertEqual(expected, actual)
 def test_find_n_for_key_pqrstuv(self):
     input = 'pqrstuv'
     expected = 1048970
     actual = Day4.find_n_for_key(input, 5)
     self.assertEqual(expected, actual)