class TestBarChartWriter(object): """""" def setup(self): """Setup a worksheet with one column of data and a bar chart""" wb = Workbook() ws = wb.get_active_sheet() ws.title = 'Numbers' for i in range(10): ws.append([i]) self.piechart = BarChart() self.piechart.add_serie(Serie(Reference(ws, (0, 0), (9, 0)))) self.cw = BarChartWriter(self.piechart) self.root = Element('test') def test_write_chart(self): """check if some characteristic tags of LineChart are there""" self.cw._write_chart(self.root) tagnames = ['{%s}barChart' % CHART_NS, '{%s}valAx' % CHART_NS, '{%s}catAx' % CHART_NS] root = safe_iterator(self.root) chart_tags = [e.tag for e in root] for tag in tagnames: assert_true(tag in chart_tags, tag) def test_serialised(self): """Check the serialised file against sample""" xml = self.cw.write() expected_file = os.path.join(DATADIR, "writer", "expected", "BarChart.xml") with open(expected_file) as expected: diff = compare_xml(xml, expected.read()) assert diff is None, diff
def test_serialised(self, bar_chart_2): """Check the serialised file against sample""" cw = BarChartWriter(bar_chart_2) xml = cw.write() tree = fromstring(xml) chart_schema.assertValid(tree) expected_file = os.path.join(DATADIR, "writer", "expected", "BarChart.xml") with open(expected_file) as expected: diff = compare_xml(xml, expected.read()) assert diff is None, diff
def test_serialised(self, bar_chart, datadir): """Check the serialised file against sample""" cw = BarChartWriter(bar_chart) xml = cw.write() tree = fromstring(xml) chart_schema.assertValid(tree) datadir.chdir() with open("BarChart.xml") as expected: diff = compare_xml(xml, expected.read()) assert diff is None, diff