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):
def test_run_generate(self):
data = encodestring(DOCUMENT_STRING)
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[0], 200)
......
......@@ -120,7 +120,7 @@ class OOHandler:
openoffice.start()
command = self._getCommand(*feature_list, **kw)
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)
self.document.restoreOriginal()
openoffice.restart()
......
......@@ -264,7 +264,7 @@ class TestServer(cloudoooTestCase):
output_msg = 'Zip archive data, at least v2.0 to extract\n'
self._testConvertFile("data/test.zip",
join(self.tmp_url, "output_zipfile.zip"),
'html',
'zip',
'txt',
output_msg,
True)
......@@ -274,7 +274,7 @@ class TestServer(cloudoooTestCase):
output_url = join(self.tmp_url, "output.txt")
self._testConvertFile("data/test.zip",
output_url,
'html',
'zip',
'txt',
'ASCII text\n')
......@@ -375,9 +375,8 @@ class TestServer(cloudoooTestCase):
self.assertEquals(response_code, 402)
self.assertEquals(type(response_dict), DictType)
self.assertEquals(response_dict, {})
msg = 'No JSON object could be decoded'
self.assertEquals(response_message,
'No JSON object could be decoded',
msg = "This document can not be loaded or is empty\n"
self.assertTrue(response_message.endswith(msg),
"%s != %s" % (response_message, msg))
def testRunGenerateMethod(self):
......
......@@ -27,6 +27,7 @@
##############################################################################
import unittest
import json
import pkg_resources
from cloudooo.application.openoffice import openoffice
from subprocess import Popen, PIPE
......@@ -62,7 +63,7 @@ class TestUnoMimeMapper(cloudoooTestCase):
stdout, stderr = Popen(' '.join(command), shell=True,
stdout=PIPE, stderr=PIPE).communicate()
self.assertEquals(stderr, '')
exec(stdout)
filter_dict, type_dict = json.loads(stdout)
self.assertEquals('filter_dict' in locals(), True)
self.assertEquals('type_dict' in locals(), True)
self.assertNotEquals(filter_dict.get('writer8'), None)
......@@ -82,7 +83,7 @@ class TestUnoMimeMapper(cloudoooTestCase):
stdout, stderr = Popen(' '.join(command), shell=True,
stdout=PIPE, stderr=PIPE).communicate()
self.assertEquals(stderr, '')
exec(stdout)
filter_dict, type_dict = json.loads(stdout)
self.assertEquals('filter_dict' in locals(), True)
self.assertEquals('type_dict' in locals(), True)
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