def test_handle_newline(self): cube = self.cube cube.attributes['lines'] = 'first\nsecond' representer = CubeRepresentation(cube) representer._get_bits(representer._get_lines()) result = representer._make_content() self.assertIn('first<br>second', result)
class Test__make_content(tests.IrisTest): def setUp(self): self.cube = stock.simple_3d() self.representer = CubeRepresentation(self.cube) self.representer._get_bits(self.representer._get_lines()) self.result = self.representer._make_content() def test_included(self): included = 'Dimension coordinates' self.assertIn(included, self.result) dim_coord_names = [c.name() for c in self.cube.dim_coords] for coord_name in dim_coord_names: self.assertIn(coord_name, self.result) def test_not_included(self): # `stock.simple_3d()` only contains the `Dimension coordinates` attr. not_included = list(self.representer.str_headings.keys()) not_included.pop(not_included.index('Dimension coordinates:')) for heading in not_included: self.assertNotIn(heading, self.result) def test_handle_newline(self): cube = self.cube cube.attributes['lines'] = 'first\nsecond' representer = CubeRepresentation(cube) representer._get_bits(representer._get_lines()) result = representer._make_content() self.assertIn('first<br>second', result)
class TestScalarCube(tests.IrisTest): def setUp(self): self.cube = stock.realistic_3d()[0, 0, 0] self.representer = CubeRepresentation(self.cube) self.representer.repr_html() def test_identfication(self): # Is this scalar cube accurately identified? self.assertTrue(self.representer.scalar_cube) def test_header__name(self): header = self.representer._make_header() expected_name = escape(self.cube.name().title().replace('_', ' ')) self.assertIn(expected_name, header) def test_header__units(self): header = self.representer._make_header() expected_units = escape(self.cube.units.symbol) self.assertIn(expected_units, header) def test_header__scalar_str(self): # Check that 'scalar cube' is placed in the header. header = self.representer._make_header() expected_str = '(scalar cube)' self.assertIn(expected_str, header) def test_content__scalars(self): # Check an element "Scalar coordinates" is present in the main content. content = self.representer._make_content() expected_str = 'Scalar coordinates' self.assertIn(expected_str, content) def test_content__specific_scalar_coord(self): # Check a specific scalar coord is present in the main content. content = self.representer._make_content() expected_coord = self.cube.coords()[0] expected_coord_name = escape(expected_coord.name()) self.assertIn(expected_coord_name, content) expected_coord_val = escape(str(expected_coord.points[0])) self.assertIn(expected_coord_val, content) def test_content__attributes(self): # Check an element "attributes" is present in the main content. content = self.representer._make_content() expected_str = 'Attributes' self.assertIn(expected_str, content)
class TestScalarCube(tests.IrisTest): def setUp(self): self.cube = stock.realistic_3d()[0, 0, 0] self.representer = CubeRepresentation(self.cube) self.representer.repr_html() def test_identfication(self): # Is this scalar cube accurately identified? self.assertTrue(self.representer.scalar_cube) def test_header__name(self): header = self.representer._make_header() expected_name = self.cube.name().title().replace('_', ' ') self.assertIn(expected_name, header) def test_header__units(self): header = self.representer._make_header() expected_units = self.cube.units.symbol self.assertIn(expected_units, header) def test_header__scalar_str(self): # Check that 'scalar cube' is placed in the header. header = self.representer._make_header() expected_str = '(scalar cube)' self.assertIn(expected_str, header) def test_content__scalars(self): # Check an element "Scalar coordinates" is present in the main content. content = self.representer._make_content() expected_str = 'Scalar coordinates' self.assertIn(expected_str, content) def test_content__specific_scalar_coord(self): # Check a specific scalar coord is present in the main content. content = self.representer._make_content() expected_coord = self.cube.coords()[0] expected_coord_name = expected_coord.name() self.assertIn(expected_coord_name, content) expected_coord_val = str(expected_coord.points[0]) self.assertIn(expected_coord_val, content) def test_content__attributes(self): # Check an element "attributes" is present in the main content. content = self.representer._make_content() expected_str = 'Attributes' self.assertIn(expected_str, content)
class Test__make_content(tests.IrisTest): def setUp(self): self.cube = stock.simple_3d() self.representer = CubeRepresentation(self.cube) self.representer._get_bits(self.representer._get_lines()) self.result = self.representer._make_content() def test_included(self): included = "Dimension coordinates" self.assertIn(included, self.result) dim_coord_names = [c.name() for c in self.cube.dim_coords] for coord_name in dim_coord_names: self.assertIn(coord_name, self.result) def test_not_included(self): # `stock.simple_3d()` only contains the `Dimension coordinates` attr. not_included = list(self.representer.str_headings.keys()) not_included.pop(not_included.index("Dimension coordinates:")) for heading in not_included: self.assertNotIn(heading, self.result)
class Test__make_content(tests.IrisTest): def setUp(self): self.cube = stock.simple_3d() self.representer = CubeRepresentation(self.cube) self.representer._get_bits(self.representer._get_lines()) self.result = self.representer._make_content() def test_included(self): included = 'Dimension coordinates' self.assertIn(included, self.result) dim_coord_names = [c.name() for c in self.cube.dim_coords] for coord_name in dim_coord_names: self.assertIn(coord_name, self.result) def test_not_included(self): # `stock.simple_3d()` only contains the `Dimension coordinates` attr. not_included = list(self.representer.str_headings.keys()) not_included.pop(not_included.index('Dimension coordinates:')) for heading in not_included: self.assertNotIn(heading, self.result)