Пример #1
0
    def test_part_one(self):
        "Test part one example of Dive object"

        # 1. Create Dive object from text
        myobj = dive.Dive(text=aoc_02.from_text(PART_ONE_TEXT))

        # 2. Check the part one result
        self.assertEqual(myobj.part_one(verbose=False), PART_ONE_RESULT)
Пример #2
0
    def test_part_two(self):
        "Test part two example of Dive object"

        # 1. Create Dive object from text
        myobj = dive.Dive(part2=True, text=aoc_02.from_text(PART_TWO_TEXT))

        # 2. Check the part two result
        self.assertEqual(myobj.part_two(verbose=False), PART_TWO_RESULT)
Пример #3
0
    def test_text_init(self):
        "Test the Passwords object creation from text"

        # 1. Create Passwords object from text
        myobj = passwords.Passwords(text=aoc_02.from_text(EXAMPLE_TEXT))

        # 2. Make sure it has the expected values
        self.assertEqual(myobj.part2, False)
        self.assertEqual(len(myobj.text), 3)
Пример #4
0
    def test_text_init(self):
        "Test the NoMath object creation from text"

        # 1. Create Math object from text
        myobj = nomath.NoMath(text=aoc_02.from_text(EXAMPLE_TEXT))

        # 2. Make sure it has the expected values
        self.assertEqual(myobj.part2, False)
        self.assertEqual(len(myobj.text), 2)
        self.assertEqual(len(myobj.presents), 2)
Пример #5
0
    def test_text_init(self):
        "Test the Dive object creation from text"

        # 1. Create Dive object from text
        myobj = dive.Dive(text=aoc_02.from_text(EXAMPLE_TEXT))

        # 2. Make sure it has the expected values
        self.assertEqual(myobj.part2, False)
        self.assertEqual(len(myobj.text), 6)
        self.assertEqual(myobj.hor, 0)
        self.assertEqual(myobj.depth, 0)
        self.assertEqual(myobj.aim, 0)
Пример #6
0
    def test_text_init(self):
        """Test Spreadsheet object creation from text"""

        # 1. Create Spreadsheet object from text
        myss = spreadsheet.Spreadsheet(text=aoc_02.from_text(P1_EXAMPLE_TEXT))

        # 2. Make sure it has the specified values
        self.assertEqual(len(myss.text), 3)
        self.assertEqual(myss.part2, False)

        # 3. Check methods
        self.assertEqual(myss.checksum(), 18)
Пример #7
0
    def test_text_init(self):
        "Test the Keypad object creation from text"

        # 1. Create Keypad object from text
        myobj = keypad.Keypad(text=aoc_02.from_text(EXAMPLE_TEXT))

        # 2. Make sure it has the expected values
        self.assertEqual(myobj.part2, False)
        self.assertEqual(len(myobj.text), 4)
        self.assertEqual(keypad.KEYPAD_ONE[myobj.location], '5')

        # 3. Check methods
        self.assertEqual(myobj.get_code(), "1985")