class Test_make_content(tests.IrisTest): def setUp(self): self.cubes = CubeList([stock.simple_3d(), stock.lat_lon_cube()]) self.cubes[0].rename('name & <html>') self.representer = CubeListRepresentation(self.cubes) self.content = self.representer.make_content() def test_repr_len(self): self.assertEqual(len(self.cubes), len(self.content)) def test_summary_lines(self): names = [c.name() for c in self.cubes] for name, content in zip(names, self.content): name = escape(name) self.assertIn(name, content) def test__cube_name_summary_consistency(self): # Just check the first cube in the CubeList. single_cube_html = self.content[0] first_contents_line = single_cube_html.split('\n')[1] # Get a "prettified" cube name, as it should be in the cubelist repr. cube_name = self.cubes[0].name() pretty_cube_name = cube_name.strip().replace('_', ' ').title() pretty_escaped_name = escape(pretty_cube_name) self.assertIn(pretty_escaped_name, single_cube_html)
class Test_make_content(tests.IrisTest): def setUp(self): self.cubes = CubeList([stock.simple_3d(), stock.lat_lon_cube()]) self.representer = CubeListRepresentation(self.cubes) self.content = self.representer.make_content() def test_repr_len(self): self.assertEqual(len(self.cubes), len(self.content)) def test_summary_lines(self): names = [c.name() for c in self.cubes] for name, content in zip(names, self.content): self.assertIn(name, content) def test__cube_name_summary_consistency(self): # Just check the first cube in the CubeList. single_cube_html = self.content[0] first_contents_line = single_cube_html.split('\n')[1] # Get the cube name out of the repr html... cube_name = first_contents_line.split('>0: ')[1].split('/')[0] # ... and prettify it (to be the same as in the following cube repr). pretty_cube_name = cube_name.strip().replace('_', ' ').title() self.assertIn(pretty_cube_name, single_cube_html)