[Erp5-report] r13648 - /erp5/trunk/utils/oood/

nobody at svn.erp5.org nobody at svn.erp5.org
Mon Mar 26 15:20:50 CEST 2007


Author: bartek
Date: Mon Mar 26 15:20:47 2007
New Revision: 13648

URL: http://svn.erp5.org?rev=13648&view=rev
Log:
tidying up of basic test suite

Added:
    erp5/trunk/utils/oood/testOoodBasicOperations.py   (with props)
    erp5/trunk/utils/oood/testOoodOldFormats.py   (with props)
Removed:
    erp5/trunk/utils/oood/test_new.py
    erp5/trunk/utils/oood/test_server.py
    erp5/trunk/utils/oood/test_timeout.py

Added: erp5/trunk/utils/oood/testOoodBasicOperations.py
URL: http://svn.erp5.org/erp5/trunk/utils/oood/testOoodBasicOperations.py?rev=13648&view=auto
==============================================================================
--- erp5/trunk/utils/oood/testOoodBasicOperations.py (added)
+++ erp5/trunk/utils/oood/testOoodBasicOperations.py Mon Mar 26 15:20:47 2007
@@ -1,0 +1,149 @@
+#!/usr/bin/python
+##############################################################################
+#
+# Copyright (c) 2002, 2006 Nexedi SARL and Contributors. All Rights Reserved.
+#                    Jean-Paul Smets-Solanes <jp at nexedi.com>
+#
+# WARNING: This program as such is intended to be used by professional
+# programmers who take the whole responsability of assessing all potential
+# consequences resulting from its eventual inadequacies and bugs
+# End users who are looking for a ready-to-use solution with commercial
+# garantees and support are strongly adviced to contract a Free Software
+# Service Company
+#
+# This program is Free Software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+#
+##############################################################################
+
+"""
+  Test various oood operations - getting and setting metadata, converting basic file types
+  to ODF, generating basic file formats
+"""
+
+import sys, base64, unittest
+from xmlrpclib import *
+sys.path.append('/etc/oood')
+import config
+
+enc = base64.encodestring
+dec = base64.decodestring
+
+try:
+  f = open('doc/test.odt')
+except IOError:
+  print "you need a doc subdir with appropriate documents"
+  sys.exit(1)
+
+sp = ServerProxy('http://%s:%d' % (config.server_host, config.server_port), allow_none=True)
+
+class TestMetaOperations(unittest.TestCase):
+
+  def testSetGetMeta(self):
+    # setting metadata
+    mime = 'application/vnd.oasis.opendocument.text'
+    newmeta = {'title':'HELLOOOOOO', 'reference':'blaaaaaah', 'MIMEType':mime}
+    data = open('doc/test.odt').read()
+    res = sp.run_setmetadata('test.odt', base64.encodestring(data), newmeta)
+    open('doc/out/test_changed.odt', 'w').write(base64.decodestring(res['data']))
+    # getting metadata back after the change
+    data = open('doc/test_changed.odt').read()
+    res = sp.run_getmetadata('test_changed.odt', base64.encodestring(data))
+    self.assertEqual(res['meta']['title'], 'HELLOOOOOO')
+    self.assertEqual(res['meta']['reference'], 'blaaaaaah')
+
+class TestFileOperations(unittest.TestCase):
+
+  def testConvertDoc(self):
+    data = open('doc/test.doc').read()
+    res = sp.run_convert('test.doc', base64.encodestring(data))
+    self.assertEqual(res['mime'], 'application/vnd.oasis.opendocument.text')
+    open('doc/out/test.odt', 'w').write(base64.decodestring(res['data']))
+
+  def testConvertXls(self):
+    data = open('doc/test.xls').read()
+    res = sp.run_convert('test.xls', base64.encodestring(data))
+    self.assertEqual(res['mime'], 'application/vnd.oasis.opendocument.spreadsheet')
+    open('doc/out/test.ods', 'w').write(base64.decodestring(res['data']))
+
+  def testConvertPpt(self):
+    data = open('doc/test.ppt').read()
+    res = sp.run_convert('test.ppt', base64.encodestring(data))
+    self.assertEqual(res['mime'],'application/vnd.oasis.opendocument.presentation')
+    open('doc/out/test.odp', 'w').write(base64.decodestring(res['data']))
+
+  def testPdfTextGeneration(self):
+    data = open('doc/test.odt').read()
+    res = sp.run_generate('test.odt', enc(data), None, 'pdf')
+    self.assert_(res)
+    self.assertEqual(res['mime'], 'application/pdf')
+    open('doc/out/test.pdf', 'w').write(base64.decodestring(res['data']))
+
+  def testPdfCalcGeneration(self):
+    data = open('doc/test.ods').read()
+    res = sp.run_generate('test.ods', enc(data), None, 'calc.pdf')
+    self.assert_(res)
+    self.assertEqual(res['mime'], 'application/pdf')
+    open('doc/out/test.calc.pdf', 'w').write(base64.decodestring(res['data']))
+
+  def testPdfImpressGeneration(self):
+    data = open('doc/test.odp').read()
+    res = sp.run_generate('test.odp', enc(data), None, 'impr.pdf')
+    self.assert_(res)
+    self.assertEqual(res['mime'], 'application/pdf')
+    open('doc/out/test.impr.pdf', 'w').write(base64.decodestring(res['data']))
+
+  def testHtmlWriterGeneration(self):
+    self.generateFile('odt', 'html-writer')
+
+  def testRtfGeneration(self):
+    self.generateFile('odt', 'rtf')
+
+  def testPptGeneration(self):
+    self.generateFile('odp', 'ppt')
+
+  def testDocGeneration(self):
+    self.generateFile('odt', 'doc')
+
+  def testTxtGeneration(self):
+    self.generateFile('odt', 'txt')
+
+  def testHtmlCalcGeneration(self):
+    self.generateFile('ods', 'html-calc')
+
+  def testCsvGeneration(self):
+    self.generateFile('ods', 'csv')
+
+  def testJpgGeneration(self):
+    self.generateFile('odg', 'jpg')
+
+  def testDrawPdfGeneration(self):
+    self.generateFile('odg', 'draw.pdf')
+
+  def generateFile(self,src,ext):
+    data = open('doc/test.%s' % src).read()
+    res = sp.run_generate('test.%s' % src, enc(data), None, ext)
+    self.assert_(res)
+    open('doc/out/test.%s' % ext, 'w').write(base64.decodestring(res['data']))
+
+if __name__=='__main__':
+  tests=(TestMetaOperations, TestFileOperations)
+  for t in tests:
+    suite = unittest.makeSuite(t)
+    unittest.TextTestRunner(verbosity=2).run(suite)
+
+
+
+
+# vim: filetype = python syntax=python shiftwidth=2 

Propchange: erp5/trunk/utils/oood/testOoodBasicOperations.py
------------------------------------------------------------------------------
    svn:executable = *

Added: erp5/trunk/utils/oood/testOoodOldFormats.py
URL: http://svn.erp5.org/erp5/trunk/utils/oood/testOoodOldFormats.py?rev=13648&view=auto
==============================================================================
--- erp5/trunk/utils/oood/testOoodOldFormats.py (added)
+++ erp5/trunk/utils/oood/testOoodOldFormats.py Mon Mar 26 15:20:47 2007
@@ -1,0 +1,97 @@
+#!/usr/bin/python
+##############################################################################
+#
+# Copyright (c) 2002, 2006 Nexedi SARL and Contributors. All Rights Reserved.
+#                    Jean-Paul Smets-Solanes <jp at nexedi.com>
+#
+# WARNING: This program as such is intended to be used by professional
+# programmers who take the whole responsability of assessing all potential
+# consequences resulting from its eventual inadequacies and bugs
+# End users who are looking for a ready-to-use solution with commercial
+# garantees and support are strongly adviced to contract a Free Software
+# Service Company
+#
+# This program is Free Software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+#
+##############################################################################
+
+"""
+  Try to convert some older OpenOffice and StarOffice file types
+  to current ODF formats
+"""
+
+import sys, base64, unittest
+from xmlrpclib import *
+sys.path.append('/etc/oood')
+import config
+
+enc = base64.encodestring
+dec = base64.decodestring
+
+sp = ServerProxy('http://%s:%d' % (config.server_host, config.server_port), allow_none = True)
+
+class TestFileOperations(unittest.TestCase):
+
+  def test_sxc2odf(self):
+    self.convertFile('sxc', 'ods', 's2o')
+
+  def test_sdc2odf(self):
+    self.convertFile('sdc', 'ods', 'sdc2o')
+
+  def test_sxw2odf(self):
+    self.convertFile('sxw', 'odt', 'sxw2o')
+
+  def test_sdw2odf(self):
+    self.convertFile('sdw', 'odt', 'sdw2o')
+
+  def test_sxi2odf(self):
+    self.convertFile('sxi', 'odp', 'sxi2o')
+
+  def test_sdd2odf(self):
+    self.convertFile('sdd', 'odp', 'sdd2o')
+
+  def test_sxd2odf(self):
+    self.convertFile('sxd', 'odg', 'sxd2o')
+
+  def test_sda2odf(self):
+    self.convertFile('sda', 'odg', 'sda2o')
+
+  def test_odg2svn(self):
+    self.generateFile('odg', 'svg')
+
+  def convertFile(self, src, ext, id=''):
+    if id: id = id + '.'
+    data=open('doc/in/test.%s%s' % (id, src)).read()
+    res=sp.run_convert('test.%s%s' % (id, src),enc(data))
+    self.assert_(res)
+    open('doc/out/test.%sout.%s' % (id, ext), 'w').write(base64.decodestring(res['data']))
+
+  def generateFile(self, src, ext, id=''):
+    if id: id = id + '.'
+    data=open('doc/in/test.%s%s' % (id, src)).read()
+    res=sp.run_generate('test.%s%s' % (id, src), enc(data), None, ext)
+    self.assert_(res)
+    open('doc/out/test.%sout.%s' % (id, ext), 'w').write(base64.decodestring(res['data']))
+
+if __name__=='__main__':
+  tests=(TestFileOperations,)
+  for t in tests:
+    suite=unittest.makeSuite(t)
+    unittest.TextTestRunner(verbosity=2).run(suite)
+
+
+
+
+# vim: filetype=python syntax=python shiftwidth=2 

Propchange: erp5/trunk/utils/oood/testOoodOldFormats.py
------------------------------------------------------------------------------
    svn:executable = *




More information about the Erp5-report mailing list