def test_puzzle_input(self):
     with open(join(dirname(__file__), 'resources', 'two_factor_authentication.txt')) as f:
         puzzle_input = f.read()
     display = PixelDisplay(width=50, height=6)
     display.execute(puzzle_input)
     ocr = OpticalCharacterRecognition(Font('5x6'))
     self.assertEqual('RURUCEOEIL', ocr.read_text(display.show_pixels()))
 def test_rect_3x2(self):
     display = PixelDisplay(width=7, height=3)
     display.rect(3, 2)
     self.assertEqual(
         '###....\n'
         '###....\n'
         '.......',
         display.show_pixels()
     )
 def test_parsing_rect_3x2(self):
     display = PixelDisplay(width=7, height=3)
     display.execute('rect 3x2')
     self.assertEqual(
         '###....\n'
         '###....\n'
         '.......',
         display.show_pixels()
     )
 def test_full_parsing(self):
     display = PixelDisplay(width=7, height=3)
     display.execute(dedent(
         """
         rect 3x2
         rotate column x=1 by 1
         rotate row y=0 by 4
         rotate column x=1 by 1
         """))
     self.assertEqual(dedent(
         """\
         .#..#.#
         #.#....
         .#.....
         """),
         display.show_pixels() + '\n'
     )
 def test_rotate_row_0_by_4(self):
     display = PixelDisplay(width=7, height=3)
     display.rect(3, 2)
     display.rotate_row(0, by=4)
     self.assertEqual(
         '....###\n'
         '###....\n'
         '.......',
         display.show_pixels()
     )
 def test_rotate_column_1_by_1(self):
     display = PixelDisplay(width=7, height=3)
     display.rect(3, 2)
     display.rotate_column(1, by=1)
     self.assertEqual(
         '#.#....\n'
         '###....\n'
         '.#.....',
         display.show_pixels()
     )
 def test_parsing_rotate_row_0_by_4(self):
     display = PixelDisplay(width=7, height=3)
     display.rect(3, 2)
     display.execute('rotate row y=0 by 4')
     self.assertEqual(
         '....###\n'
         '###....\n'
         '.......',
         display.show_pixels()
     )
 def test_parsing_rotate_column_1_by_1(self):
     display = PixelDisplay(width=7, height=3)
     display.rect(3, 2)
     display.execute('rotate column x=1 by 1')
     self.assertEqual(
         '#.#....\n'
         '###....\n'
         '.#.....',
         display.show_pixels()
     )
 def test_puzzle_input(self):
     with open(join(dirname(__file__), 'resources', 'two_factor_authentication.txt')) as f:
         puzzle_input = f.read()
     display = PixelDisplay(width=50, height=6)
     display.execute(puzzle_input)
     self.assertEqual(121, display.pixels_on())