Example #1
0
class TestLineChartWriter(object):

    def setup(self):
        """Setup a worksheet with one column of data and a line chart"""
        wb = Workbook()
        ws = wb.get_active_sheet()
        ws.title = 'Line'
        for i in range(1, 5):
            ws.append([i])
        self.piechart = LineChart()
        self.piechart.add_serie(Serie(Reference(ws, (0, 0), (4, 0))))
        self.cw = LineChartWriter(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}lineChart' % 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", "LineChart.xml")
        with open(expected_file) as expected:
            diff = compare_xml(xml, expected.read())
            assert diff is None, diff
Example #2
0
 def test_serialised(self, line_chart):
     """Check the serialised file against sample"""
     cw = LineChartWriter(line_chart)
     xml = cw.write()
     tree = fromstring(xml)
     chart_schema.assertValid(tree)
     expected_file = os.path.join(DATADIR, "writer", "expected", "LineChart.xml")
     with open(expected_file) as expected:
         diff = compare_xml(xml, expected.read())
         assert diff is None, diff
Example #3
0
 def test_serialised(self, line_chart, datadir):
     """Check the serialised file against sample"""
     cw = LineChartWriter(line_chart)
     xml = cw.write()
     tree = fromstring(xml)
     chart_schema.assertValid(tree)
     datadir.chdir()
     with open("LineChart.xml") as expected:
         diff = compare_xml(xml, expected.read())
         assert diff is None, diff
Example #4
0
 def test_serialised(self, line_chart):
     """Check the serialised file against sample"""
     cw = LineChartWriter(line_chart)
     xml = cw.write()
     tree = fromstring(xml)
     chart_schema.assertValid(tree)
     expected_file = os.path.join(DATADIR, "writer", "expected",
                                  "LineChart.xml")
     with open(expected_file) as expected:
         diff = compare_xml(xml, expected.read())
         assert diff is None, diff
Example #5
0
    def test_write_chart(self, line_chart):
        """check if some characteristic tags of LineChart are there"""
        cw = LineChartWriter(line_chart)
        cw._write_chart()
        tagnames = ['{%s}lineChart' % CHART_NS,
                    '{%s}valAx' % CHART_NS,
                    '{%s}catAx' % CHART_NS]

        root = safe_iterator(cw.root)
        chart_tags = [e.tag for e in root]
        for tag in tagnames:
            assert tag in chart_tags
Example #6
0
    def test_write_chart(self, line_chart):
        """check if some characteristic tags of LineChart are there"""
        cw = LineChartWriter(line_chart)
        cw._write_chart()
        tagnames = ['{%s}lineChart' % CHART_NS,
                    '{%s}valAx' % CHART_NS,
                    '{%s}catAx' % CHART_NS]

        root = safe_iterator(cw.root)
        chart_tags = [e.tag for e in root]
        for tag in tagnames:
            assert tag in chart_tags
Example #7
0
 def setup(self):
     """Setup a worksheet with one column of data and a line chart"""
     wb = Workbook()
     ws = wb.get_active_sheet()
     ws.title = 'Line'
     for i in range(1, 5):
         ws.append([i])
     self.piechart = LineChart()
     self.piechart.add_serie(Serie(Reference(ws, (0, 0), (4, 0))))
     self.cw = LineChartWriter(self.piechart)
     self.root = Element('test')