testchart.py 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. # Copyright (C) 2007 Søren Roug, European Environment Agency
  4. #
  5. # This is free software. You may redistribute it under the terms
  6. # of the Apache license and the GNU General Public License Version
  7. # 2 or at your option any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public
  15. # License along with this program; if not, write to the Free Software
  16. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. #
  18. # Contributor(s):
  19. #
  20. import unittest
  21. from odf import chart
  22. from odf.element import IllegalChild
  23. class TestChartElements(unittest.TestCase):
  24. def testChart(self):
  25. """ Check chart doesn't allow 'Major' as class """
  26. chart.Chart( width="8cm", height="7cm", attributes={'class':'chart:circle'})
  27. self.assertRaises(ValueError, chart.Chart, attributes={'class':'Major'})
  28. def testLegend(self):
  29. chart.Legend()
  30. self.assertRaises(AttributeError, chart.Legend, attributes={'class':'Major'})
  31. chart.Legend(legendposition="end")
  32. self.assertRaises(ValueError, chart.Legend, legendposition="nowhere")
  33. def testNoClass(self):
  34. """ Check that 'name' is required """
  35. self.assertRaises(AttributeError, chart.Chart)
  36. def testGrid(self):
  37. self.assertRaises(ValueError, chart.Grid, attributes={'class':'chart:circle'})
  38. self.assertRaises(ValueError, chart.Grid, attributes={'class':'Major'})
  39. chart.Grid(attributes={'class':'major'})
  40. chart.Grid(attributes={'class':'minor'})
  41. if __name__ == '__main__':
  42. unittest.main()