def test_horizontal_container_min_width(self): fill1 = Fill('1') fill1.min_width = 7 fill2 = Fill('2') horizontal_container = HorizontalContainer([fill1, fill2]) self.assertEqual(horizontal_container.min_width, 8) fill2.min_width = 34 self.assertEqual(horizontal_container.min_width, 42)
def test_horizontal_container_max_width(self): fill1 = Fill('1') fill1.max_width = 30 fill2 = Fill('2') horizontal_container = HorizontalContainer([fill1, fill2]) self.assertIsNone(horizontal_container.max_width) fill2.max_width = 11 self.assertEqual(horizontal_container.max_width, 42)
def test_fill(self): fill = Fill() self.assertEqual(fill.draw(10, 0), '') self.assertEqual(fill.draw(10, 1), '.' * 10) self.assertEqual(fill.draw(2, 2), '..\n..') self.assertEqual(fill.draw(0, 10), '\n' * 9) fill = Fill('o') self.assertEqual(fill.draw(1, 1), 'o')
def test_horizontal_container_constraints(self): fill1 = Fill('1') fill2 = Fill('2') horizontal_container = HorizontalContainer([fill1, fill2]) fill4 = Fill('4') fill4.max_width = 2 horizontal_container.add_element(fill4) self.assertEqual(horizontal_container.draw(10, 1), '111 222 44') self.assertEqual(horizontal_container.draw(5, 1), '1 2 4') fill4.max_width = None fill4.min_width = 3 self.assertEqual(horizontal_container.draw(7, 1), '1 2 444') self.assertEqual(horizontal_container.draw(14, 1), '1111 2222 4444') fill4.max_width = fill4.min_width = 5 self.assertEqual(horizontal_container.draw(9, 1), '1 2 44444') self.assertEqual( horizontal_container.draw(19, 1), '111111 222222 44444') horizontal_container.remove_element(fill2) self.assertEqual(horizontal_container.draw(7, 1), '1 44444') self.assertEqual(horizontal_container.draw(14, 1), '11111111 44444') fill1.min_width = 3 self.assertEqual(horizontal_container.draw(9, 1), '111 44444')