[Erp5-report] r14508 - /erp5/trunk/utils/oood/testOoodAllFormatsSupport.py

nobody at svn.erp5.org nobody at svn.erp5.org
Wed May 16 18:29:38 CEST 2007


Author: bartek
Date: Wed May 16 18:29:37 2007
New Revision: 14508

URL: http://svn.erp5.org?rev=14508&view=rev
Log:
a test for all supported formats

Added:
    erp5/trunk/utils/oood/testOoodAllFormatsSupport.py   (with props)

Added: erp5/trunk/utils/oood/testOoodAllFormatsSupport.py
URL: http://svn.erp5.org/erp5/trunk/utils/oood/testOoodAllFormatsSupport.py?rev=14508&view=auto
==============================================================================
--- erp5/trunk/utils/oood/testOoodAllFormatsSupport.py (added)
+++ erp5/trunk/utils/oood/testOoodAllFormatsSupport.py Wed May 16 18:29:37 2007
@@ -1,0 +1,96 @@
+#!/usr/bin/python
+##############################################################################
+#
+# Copyright (c) 2002, 2006 Nexedi SARL and Contributors. All Rights Reserved.
+#                    Bartlomiej Gorny <bartek at erp5.pl>
+#
+# 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
+import re
+from xmlrpclib import *
+import config
+from oood_common import responseFactory, Request
+from mimemapper import mimemapper
+
+enc = base64.encodestring
+
+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))
+
+class TestFormats(unittest.TestCase):
+
+  def testTextFormats(self):
+    self.runTestForType('text', 'doc/test.odt')
+
+  def testSpreadsheetFormats(self):
+    self.runTestForType('spreadsheet', 'doc/test.ods')
+
+  def testPresentationFormats(self):
+    self.runTestForType('presentation', 'doc/test.odp')
+
+  def testDrawingFormats(self):
+    self.runTestForType('drawing', 'doc/test.odg')
+
+  def runTestForType(self, type, filename):
+    data = open(filename).read()
+    failed_format_list = []
+    print '\ntesting %s, generating %s formats...' % (type.title(), len(mimemapper.document_type_dict[type]))
+    for extension in mimemapper.document_type_dict[type]:
+      request = Request(filename=filename, extension=extension, data=data)
+      res = sp.generate(request)
+      res = responseFactory(res)
+      if res.code == 200:
+        msg = 'PASSED'
+        newname = 'doc/out/test_changed.%s' % extension
+        if res.mime == 'application/zip':
+          newname += '.zip'
+        open(newname, 'w').write(res.data)
+      else:
+        msg = 'FAILED (%s)' % res.code
+        failed_format_list.append(extension)
+      print '%-15s\t...%s' % (extension, msg)
+    self.failIf(failed_format_list, 'Failed for %s on: %s' % (type.title(), ', '.join(failed_format_list)))
+
+
+if __name__=='__main__':
+  tests=(TestFormats,)
+  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/testOoodAllFormatsSupport.py
------------------------------------------------------------------------------
    svn:executable = *




More information about the Erp5-report mailing list