Commit 125b1901 authored by Gabriel Monnerat's avatar Gabriel Monnerat

update tests and fix regex to extract the exception on stderr

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk/utils@41773 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 54f62121
...@@ -20,7 +20,7 @@ class CloudoooTestCase(unittest.TestCase): ...@@ -20,7 +20,7 @@ class CloudoooTestCase(unittest.TestCase):
def test_run_generate(self): def test_run_generate(self):
data = encodestring(DOCUMENT_STRING) data = encodestring(DOCUMENT_STRING)
proxy = ServerProxy(self.proxy_address, allow_none=True) proxy = ServerProxy(self.proxy_address, allow_none=True)
res = proxy.run_generate("t.text", data, None, 'pdf', 'txt') res = proxy.run_generate("t.text", data, None, 'pdf', 'text/plain')
self.assertEquals(res[1]['mime'], "application/pdf") self.assertEquals(res[1]['mime'], "application/pdf")
self.assertEquals(res[0], 200) self.assertEquals(res[0], 200)
......
...@@ -120,7 +120,7 @@ class OOHandler: ...@@ -120,7 +120,7 @@ class OOHandler:
openoffice.start() openoffice.start()
command = self._getCommand(*feature_list, **kw) command = self._getCommand(*feature_list, **kw)
stdout, stderr = self._subprocess(command) stdout, stderr = self._subprocess(command)
if not stdout and len(re.findall("[A-Za-z]*Exception", stderr)) >= 1: if not stdout and len(re.findall("\w*Exception|\w*Error", stderr)) >= 1:
logger.debug(stderr) logger.debug(stderr)
self.document.restoreOriginal() self.document.restoreOriginal()
openoffice.restart() openoffice.restart()
......
...@@ -264,7 +264,7 @@ class TestServer(cloudoooTestCase): ...@@ -264,7 +264,7 @@ class TestServer(cloudoooTestCase):
output_msg = 'Zip archive data, at least v2.0 to extract\n' output_msg = 'Zip archive data, at least v2.0 to extract\n'
self._testConvertFile("data/test.zip", self._testConvertFile("data/test.zip",
join(self.tmp_url, "output_zipfile.zip"), join(self.tmp_url, "output_zipfile.zip"),
'html', 'zip',
'txt', 'txt',
output_msg, output_msg,
True) True)
...@@ -274,7 +274,7 @@ class TestServer(cloudoooTestCase): ...@@ -274,7 +274,7 @@ class TestServer(cloudoooTestCase):
output_url = join(self.tmp_url, "output.txt") output_url = join(self.tmp_url, "output.txt")
self._testConvertFile("data/test.zip", self._testConvertFile("data/test.zip",
output_url, output_url,
'html', 'zip',
'txt', 'txt',
'ASCII text\n') 'ASCII text\n')
...@@ -375,9 +375,8 @@ class TestServer(cloudoooTestCase): ...@@ -375,9 +375,8 @@ class TestServer(cloudoooTestCase):
self.assertEquals(response_code, 402) self.assertEquals(response_code, 402)
self.assertEquals(type(response_dict), DictType) self.assertEquals(type(response_dict), DictType)
self.assertEquals(response_dict, {}) self.assertEquals(response_dict, {})
msg = 'No JSON object could be decoded' msg = "This document can not be loaded or is empty\n"
self.assertEquals(response_message, self.assertTrue(response_message.endswith(msg),
'No JSON object could be decoded',
"%s != %s" % (response_message, msg)) "%s != %s" % (response_message, msg))
def testRunGenerateMethod(self): def testRunGenerateMethod(self):
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
############################################################################## ##############################################################################
import unittest import unittest
import json
import pkg_resources import pkg_resources
from cloudooo.application.openoffice import openoffice from cloudooo.application.openoffice import openoffice
from subprocess import Popen, PIPE from subprocess import Popen, PIPE
...@@ -62,7 +63,7 @@ class TestUnoMimeMapper(cloudoooTestCase): ...@@ -62,7 +63,7 @@ class TestUnoMimeMapper(cloudoooTestCase):
stdout, stderr = Popen(' '.join(command), shell=True, stdout, stderr = Popen(' '.join(command), shell=True,
stdout=PIPE, stderr=PIPE).communicate() stdout=PIPE, stderr=PIPE).communicate()
self.assertEquals(stderr, '') self.assertEquals(stderr, '')
exec(stdout) filter_dict, type_dict = json.loads(stdout)
self.assertEquals('filter_dict' in locals(), True) self.assertEquals('filter_dict' in locals(), True)
self.assertEquals('type_dict' in locals(), True) self.assertEquals('type_dict' in locals(), True)
self.assertNotEquals(filter_dict.get('writer8'), None) self.assertNotEquals(filter_dict.get('writer8'), None)
...@@ -82,7 +83,7 @@ class TestUnoMimeMapper(cloudoooTestCase): ...@@ -82,7 +83,7 @@ class TestUnoMimeMapper(cloudoooTestCase):
stdout, stderr = Popen(' '.join(command), shell=True, stdout, stderr = Popen(' '.join(command), shell=True,
stdout=PIPE, stderr=PIPE).communicate() stdout=PIPE, stderr=PIPE).communicate()
self.assertEquals(stderr, '') self.assertEquals(stderr, '')
exec(stdout) filter_dict, type_dict = json.loads(stdout)
self.assertEquals('filter_dict' in locals(), True) self.assertEquals('filter_dict' in locals(), True)
self.assertEquals('type_dict' in locals(), True) self.assertEquals('type_dict' in locals(), True)
self.assertNotEquals(filter_dict.get('writer8'), None) self.assertNotEquals(filter_dict.get('writer8'), None)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment