testpicture.py 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. # Copyright (C) 2016 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, os
  21. from odf import thumbnail
  22. from odf.element import IllegalChild
  23. from odf.opendocument import OpenDocumentText, load
  24. from odf import text
  25. from odf.namespaces import TEXTNS
  26. class TestPicture(unittest.TestCase):
  27. def testAddPicture(self):
  28. """ Check that AddPicture works"""
  29. THUMBNAILNAME = "thumbnail.png"
  30. icon = thumbnail.thumbnail()
  31. f = open(THUMBNAILNAME, "wb")
  32. f.write(icon)
  33. f.close()
  34. textdoc = OpenDocumentText()
  35. textdoc.addPicture(THUMBNAILNAME)
  36. os.unlink(THUMBNAILNAME)
  37. if __name__ == '__main__':
  38. unittest.main()