class Test__make_row(tests.IrisTest): def setUp(self): self.cube = stock.simple_3d() cm = CellMethod('mean', 'time', '6hr') self.cube.add_cell_method(cm) self.representer = CubeRepresentation(self.cube) self.representer._get_bits(self.representer._get_lines()) def test__title_row(self): title = 'Wibble:' row = self.representer._make_row(title) # A cell for the title, an empty cell for each cube dimension, plus row # opening and closing tags. expected_len = self.cube.ndim + 3 self.assertEqual(len(row), expected_len) # Check for specific content. row_str = '\n'.join(element for element in row) self.assertIn(title.strip(':'), row_str) expected_html_class = 'iris-title' self.assertIn(expected_html_class, row_str) def test__inclusion_row(self): # An inclusion row has x/- to indicate whether a coordinate describes # a dimension. title = 'time' body = ['x', '-', '-', '-'] row = self.representer._make_row(title, body) # A cell for the title, a cell for each cube dimension, plus row # opening and closing tags. expected_len = len(body) + 3 self.assertEqual(len(row), expected_len) # Check for specific content. row_str = '\n'.join(element for element in row) self.assertIn(title, row_str) self.assertIn('x', row_str) self.assertIn('-', row_str) expected_html_class_1 = 'iris-word-cell' expected_html_class_2 = 'iris-inclusion-cell' self.assertIn(expected_html_class_1, row_str) self.assertIn(expected_html_class_2, row_str) # We do not expect a colspan to be set. self.assertNotIn('colspan', row_str) def test__attribute_row(self): # An attribute row does not contain inclusion indicators. title = 'source' body = 'Iris test case' colspan = 5 row = self.representer._make_row(title, body, colspan) # We only expect two cells here: the row title cell and one other cell # that spans a number of columns. We also need to open and close the # tr html element, giving 4 bits making up the row. self.assertEqual(len(row), 4) # Check for specific content. row_str = '\n'.join(element for element in row) self.assertIn(title, row_str) self.assertIn(body, row_str) # We expect a colspan to be set. colspan_str = 'colspan="{}"'.format(colspan) self.assertIn(colspan_str, row_str)
class Test__make_row(tests.IrisTest): def setUp(self): self.cube = stock.simple_3d() cm = CellMethod('mean', 'time', '6hr') self.cube.add_cell_method(cm) self.representer = CubeRepresentation(self.cube) self.representer._get_bits(self.representer._get_lines()) def test__title_row(self): title = 'Wibble:' row = self.representer._make_row(title) # A cell for the title, an empty cell for each cube dimension, plus row # opening and closing tags. expected_len = self.cube.ndim + 3 self.assertEqual(len(row), expected_len) # Check for specific content. row_str = '\n'.join(element for element in row) self.assertIn(title.strip(':'), row_str) expected_html_class = 'iris-title' self.assertIn(expected_html_class, row_str) def test__inclusion_row(self): # An inclusion row has x/- to indicate whether a coordinate describes # a dimension. title = 'time' body = ['x', '-', '-', '-'] row = self.representer._make_row(title, body) # A cell for the title, a cell for each cube dimension, plus row # opening and closing tags. expected_len = len(body) + 3 self.assertEqual(len(row), expected_len) # Check for specific content. row_str = '\n'.join(element for element in row) self.assertIn(title, row_str) self.assertIn('x', row_str) self.assertIn('-', row_str) expected_html_class_1 = 'iris-word-cell' expected_html_class_2 = 'iris-inclusion-cell' self.assertIn(expected_html_class_1, row_str) self.assertIn(expected_html_class_2, row_str) # We do not expect a colspan to be set. self.assertNotIn('colspan', row_str) def test__attribute_row(self): # An attribute row does not contain inclusion indicators. title = 'source' body = 'Iris test case' colspan = 5 row = self.representer._make_row(title, body, colspan) # We only expect two cells here: the row title cell and one other cell # that spans a number of columns. We also need to open and close the # tr html element, giving 4 bits making up the row. self.assertEqual(len(row), 4) # Check for specific content. row_str = '\n'.join(element for element in row) self.assertIn(title, row_str) self.assertIn(body, row_str) # We expect a colspan to be set. colspan_str = 'colspan="{}"'.format(colspan) self.assertIn(colspan_str, row_str)
class Test__expand_last_cell(tests.IrisTest): def setUp(self): self.cube = stock.simple_3d() self.representer = CubeRepresentation(self.cube) self.representer._get_bits(self.representer._get_lines()) col_span = self.representer.ndims self.row = self.representer._make_row('title', body='first', col_span=col_span) def test_add_line(self): cell = self.representer._expand_last_cell(self.row[-2], 'second') self.assertIn('first<br>second', cell)