Commit 4c832ec6 authored by Gabriel Monnerat's avatar Gabriel Monnerat

clean up the code. Modified test with python script because now this format is...

clean up the code. Modified test with python script because now this format is supported by OpenOffice.org

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk/utils@38983 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 3b7bbafa
...@@ -304,60 +304,33 @@ class TestServer(cloudoooTestCase): ...@@ -304,60 +304,33 @@ class TestServer(cloudoooTestCase):
'odt', 'odt',
'OpenDocument Text\n') 'OpenDocument Text\n')
def testSendInvalidFile(self): def testConvertPyToPDF(self):
"""Test to verify if the behavior of server is normal when a invalid file is """Test export python to pdf"""
sent""" self._testConvertFile("cloudoooTestCase.py",
input_url = "cloudoooTestCase.py" join(self.tmp_url, "cloudoooTestCase.py"),
error_msg = "This document can not be loaded or is empty\n" 'py',
data = encodestring(open(input_url).read()) 'pdf',
try: 'PDF document, version 1.4\n')
self.proxy.convertFile(data, 'py', 'pdf')
self.fail(error_msg)
except Fault, err:
self.assertEquals(err.faultString.endswith(error_msg), True,
err.faultString)
try:
self.proxy.getFileMetadataItemList(data, 'py')
self.fail(error_msg)
except Fault, err:
self.assertEquals(err.faultString.endswith(error_msg), True,
err.faultString)
try:
self.proxy.updateFileMetadata(data, 'odt',
{"Subject": "subject"})
self.fail(error_msg)
except Fault, err:
self.assertEquals(err.faultString.endswith(error_msg), True,
err.faultString)
def testSendEmptyRequest(self): def testSendEmptyRequest(self):
"""Test to verify if the behavior of server is normal when a empty string """Test to verify if the behavior of server is normal when a empty string
is sent""" is sent"""
data = encodestring("") data = encodestring("")
error_msg = "This document can not be loaded or is empty\n" error_msg = "This document can not be loaded or is empty\n"
fail_msg = "This document can not be loaded, it is empty\n"
try: try:
self.proxy.convertFile(data, '', '') self.proxy.convertFile(data, '', '')
self.fail(error_msg) self.fail(fail_msg)
except Fault, err: except Fault, err:
msg = "This format is not supported or is invalid" msg = "This format is not supported or is invalid"
self.assertEquals(err.faultString.endswith(msg), True, self.assertEquals(err.faultString.endswith(msg), True,
"ConvertFile\n" + err.faultString) "ConvertFile\n" + err.faultString)
try: res = self.proxy.getFileMetadataItemList(data, '')
self.proxy.getFileMetadataItemList(data, '') self.assertEquals(res['MIMEType'], "text/plain")
self.fail(error_msg) res = decodestring(self.proxy.updateFileMetadata(data, '',
except Fault, err: {"Subject": "subject"}))
self.assertEquals(err.faultString.endswith(error_msg), True, self.assertEquals(decodestring(res), '')
"getFileMetadataItemList\n" + err.faultString)
try:
self.proxy.updateFileMetadata(data, '', {"Subject": "subject"})
self.fail(error_msg)
except Fault, err:
self.assertEquals(err.faultString.endswith(error_msg), True,
"updateFileMetadata\n" + err.faultString)
def testConvertDocumentToInvalidFormat(self): def testConvertDocumentToInvalidFormat(self):
"""Try convert one document for a invalid format""" """Try convert one document for a invalid format"""
......
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