Commit 508a7cdc authored by Gabriel Monnerat's avatar Gabriel Monnerat

refactor test to pass mimemapper as list

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk/utils@39024 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 358e3cc3
...@@ -29,9 +29,8 @@ ...@@ -29,9 +29,8 @@
import unittest import unittest
import jsonpickle, pkg_resources import jsonpickle, pkg_resources
from subprocess import Popen, PIPE from subprocess import Popen, PIPE
from os.path import exists from os.path import exists, join
from cloudoooTestCase import cloudoooTestCase, make_suite from cloudoooTestCase import cloudoooTestCase, make_suite
from cloudooo.mimemapper import mimemapper
from cloudooo.application.openoffice import openoffice from cloudooo.application.openoffice import openoffice
from cloudooo.document import FileSystemDocument from cloudooo.document import FileSystemDocument
...@@ -54,24 +53,28 @@ class TestUnoConverter(cloudoooTestCase): ...@@ -54,24 +53,28 @@ class TestUnoConverter(cloudoooTestCase):
def testUnoConverterOdtToDoc(self): def testUnoConverterOdtToDoc(self):
"""Test script unoconverter""" """Test script unoconverter"""
mimemapper = dict(filter_list=[('doc',
'com.sun.star.text.TextDocument',
'MS Word 97')],
doc_type_list_by_extension=dict(doc=['com.sun.star.text.TextDocument']))
mimemapper_pickled = jsonpickle.encode(mimemapper) mimemapper_pickled = jsonpickle.encode(mimemapper)
command = [self.python_path, command = [join(self.office_binary_path, "python"),
pkg_resources.resource_filename("cloudooo", pkg_resources.resource_filename("cloudooo",
"helper/unoconverter.py"), "helper/unoconverter.py"),
"'--convert'", "'--convert'",
"'--uno_path=%s'" % self.uno_path, "--uno_path='%s'" % self.uno_path,
"'--office_binary_path=%s'" % self.office_binary_path, "--office_binary_path='%s'" % self.office_binary_path,
"'--hostname=%s'" % self.hostname, "--hostname='%s'" % self.hostname,
"'--port=%s'" % self.port, "--port='%s'" % self.port,
"'--document_url=%s'" % self.document.getUrl(), "--document_url='%s'" % self.document.getUrl(),
"'--destination_format=%s'" % "doc", "--destination_format='%s'" % "doc",
"'--source_format=%s'" % "odt", "--source_format='%s'" % "odt",
"'--mimemapper=%s'" % mimemapper_pickled] "--mimemapper='%s'" % mimemapper_pickled]
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, '')
output_url = stdout.replace('\n', '') output_url = stdout.replace('\n', '')
self.assertEquals(exists(output_url), True) self.assertEquals(exists(output_url), True, stdout)
stdout, stderr = Popen("file %s" % output_url, shell=True, stdout, stderr = Popen("file %s" % output_url, shell=True,
stdout=PIPE, stderr=PIPE).communicate() stdout=PIPE, stderr=PIPE).communicate()
self.assertEquals(self.file_msg_list[1] in stdout \ self.assertEquals(self.file_msg_list[1] in stdout \
......
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