class TestMultiTable(unittest.TestCase): def setUp(self): self.table = MultiTable() def test_max_width_calculation(self): self.table.add_title('foo') self.table.add_row_header(['one', 'two', 'three']) self.table.add_row(['one', 'two', 'three']) self.table.new_section('bar') self.table.add_row_header(['one', 'two']) self.table.add_row(['12345', '1234567'])
class TestMultiTable(unittest.TestCase): def setUp(self): self.table = MultiTable() def test_max_width_calculation(self): self.table.add_title("foo") self.table.add_row_header(["one", "two", "three"]) self.table.add_row(["one", "two", "three"]) self.table.new_section("bar") self.table.add_row_header(["one", "two"]) self.table.add_row(["12345", "1234567"])
class TestVerticalTableConversion(unittest.TestCase): def setUp(self): self.table = MultiTable() def test_convert_section_to_vertical(self): self.table.add_title("foo") self.table.add_row_header(["key1", "key2", "key3"]) self.table.add_row(["val1", "val2", "val3"]) convert_to_vertical_table(self.table._sections) # To convert to a vertical table, there should be no headers: section = self.table._sections[0] self.assertEqual(section.headers, []) # Then we should create a two column row with key val pairs. self.assertEqual(section.rows, [["key1", "val1"], ["key2", "val2"], ["key3", "val3"]])
class TestVerticalTableConversion(unittest.TestCase): def setUp(self): self.table = MultiTable() def test_convert_section_to_vertical(self): self.table.add_title('foo') self.table.add_row_header(['key1', 'key2', 'key3']) self.table.add_row(['val1', 'val2', 'val3']) convert_to_vertical_table(self.table._sections) # To convert to a vertical table, there should be no headers: section = self.table._sections[0] self.assertEqual(section.headers, []) # Then we should create a two column row with key val pairs. self.assertEqual( section.rows, [['key1', 'val1'], ['key2', 'val2'], ['key3', 'val3']])