testdrawelement.py 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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 draw, svg
  22. from odf.element import IllegalChild
  23. class TestDrawElements(unittest.TestCase):
  24. def testNoName(self):
  25. """ Check that 'name' is required """
  26. self.assertRaises(AttributeError, draw.FillImage, href="y")
  27. def testFloatingPoints(self):
  28. """ Points that are floating point are not allowed """
  29. self.assertRaises(ValueError, draw.Polygon, points='0.0000,0.0000 -30.9017,95.1057', viewbox="-1000 -1000 1000 1000")
  30. self.assertRaises(ValueError, draw.Polygon, points='0.0000,0.0000 -30,95.7', viewbox="-1000 -1000 1000 1000")
  31. def testViewbox(self):
  32. """ ViewBox can only have four integer values """
  33. self.assertRaises(ValueError, draw.Polygon, points='0,0 -30,957', viewbox="-1000.0 -1000.0 1000 1000")
  34. self.assertRaises(ValueError, draw.Polygon, points='0,0 -30,957', viewbox="-1000 -1000 1000 1000.1")
  35. self.assertRaises(ValueError, draw.Polygon, points='0,0 -30,957', viewbox="-1000 -1000 1000")
  36. def testIntPoints(self):
  37. """ Points can only be integers """
  38. draw.Polygon(points='0,0 -31,95', viewbox="-1000 -1000 1000 1000")
  39. def testCalls(self):
  40. """ Simple calls """
  41. self.assertRaises(TypeError, draw.FillImage, "x", href="y")
  42. draw.FillImage(name="x", href="y", type="simple")
  43. self.assertRaises(TypeError, draw.Gradient, "x", style="y")
  44. self.assertRaises(TypeError, draw.Hatch, "x", style="y")
  45. self.assertRaises(TypeError, draw.Marker, "x",d="y",viewbox="0 0 100 100")
  46. self.assertRaises(TypeError, draw.Opacity, "x", style="y")
  47. self.assertRaises(TypeError, draw.StrokeDash, "x")
  48. self.assertRaises(TypeError, svg.Lineargradient, "x")
  49. self.assertRaises(TypeError, svg.Radialgradient, "x")
  50. if __name__ == '__main__':
  51. unittest.main()