def test_should_accept_x(self): column = Column(50, 'title', 10) self.assertEqual(50, column.width) self.assertEqual('title', column.title) self.assertEqual(10, column.x)
def test_should_not_require_x(self): column = Column(50, 'title') self.assertEqual(50, column.width) self.assertEqual('title', column.title) self.assertEqual(None, column.x)
def get_header(self, height=15): columns = [ Column(45, 'lorem'), Column(25, 'ipsum dolor sit amet'), Column(30, 'consectetur adipisicing elit'), Column(25, 'incididunt ut labore'), Column(30, 'et dolore magna aliqua ut'), Column(25, 'enim ad minim veniam') ] return Header(height, columns)
def test_should_require_positive_height(self): with self.assertRaises(AssertionError): Header(0, Column(10, 'hello'))
def test_should_reject_non_number_x(self): with self.assertRaises(AssertionError): Column(50, 'title', '10')
def test_should_require_title_text(self): with self.assertRaises(AssertionError): Column(50, 123)
def test_should_require_positive_width(self): with self.assertRaises(AssertionError): Column(0, 'title')
def test_should_get_width_of_n_first_columns(self): columns = Column(10, 'lorem'), Column(20, 'ipsum'), Column(15, 'dolor') header = Header(10, columns) self.assertEqual(30, header.get_width(2))
def test_should_get_total_width(self): columns = Column(10, 'lorem'), Column(20, 'ipsum'), Column(15, 'dolor') header = Header(10, columns) self.assertEqual(45, header.get_width())