Commit 3a027c90 authored by Gabriel Monnerat's avatar Gabriel Monnerat

add script to test cloudooo application easily. e.g bin/cloudooo_tester.py...

add script to test cloudooo application easily. e.g bin/cloudooo_tester.py --hostname=localhost --port=8011

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk/utils@37886 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent c117519c
#!/usr/bin/env python
import unittest
import sys
from base64 import encodestring
from xmlrpclib import ServerProxy
from getopt import getopt, GetoptError
from cloudooo.utils import usage
DOCUMENT_STRING = "MemoryMonitor - TimeoutMonitor - RequestMonitor\n\nOOHandler\n\nMimemapper\n\nERP5\n"
HOSTNAME = PORT = None
class CloudoooTestCase(unittest.TestCase):
""" """
def setUp(self):
self.proxy_address = "http://%s:%s" % (HOSTNAME, PORT)
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')
self.assertEquals(res[1]['mime'], "application/pdf")
self.assertEquals(res[0], 200)
def test_set_metadata(self):
data = encodestring(DOCUMENT_STRING)
proxy = ServerProxy(self.proxy_address, allow_none=True)
odt_data = proxy.convertFile(data, 'txt', 'odt')
metadata_dict = proxy.getFileMetadataItemList(odt_data, 'odt')
self.assertEquals(metadata_dict["MIMEType"],
'application/vnd.oasis.opendocument.text')
res = proxy.run_setmetadata("t.odt", odt_data, {"Title":"test"})
self.assertEquals(res[0], 200)
response_code, response_dict, response_message = \
proxy.run_convert("t.odt", res[1]['data'])
self.assertEquals(response_code, 200)
self.assertEquals(response_dict['meta']['Title'], "test")
def main():
global PORT, HOSTNAME
try:
opt_list, arg_list = getopt(sys.argv[1:], "",
["port=","hostname="])
except GetoptError, e:
usage(sys.stderr, "%s \nUse --port and --hostname" % e)
sys.exit(2)
for opt, arg in opt_list:
if opt == "--port":
PORT = arg
elif opt == "--hostname":
HOSTNAME = arg
if not HOSTNAME and not PORT:
usage(sys.stderr, "Use --port and --hostname")
sys.exit(2)
suite = unittest.TestLoader().loadTestsFromTestCase(CloudoooTestCase)
unittest.TextTestRunner(verbosity=2).run(suite)
...@@ -36,5 +36,6 @@ setup(name='cloudooo', ...@@ -36,5 +36,6 @@ setup(name='cloudooo',
unoconverter.py = cloudooo.bin.unoconverter:main unoconverter.py = cloudooo.bin.unoconverter:main
unomimemapper.py = cloudooo.bin.unomimemapper:main unomimemapper.py = cloudooo.bin.unomimemapper:main
openoffice_tester.py = cloudooo.bin.openoffice_tester:main openoffice_tester.py = cloudooo.bin.openoffice_tester:main
cloudooo_tester.py = cloudooo.bin.cloudooo_tester:main
""", """,
) )
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