Commit a4a3dfd8 authored by Priscila Manhaes's avatar Priscila Manhaes

refactor to use cloudoootestcase

parent f530b4ce
...@@ -26,37 +26,31 @@ ...@@ -26,37 +26,31 @@
# #
############################################################################## ##############################################################################
from xmlrpclib import ServerProxy
from base64 import encodestring, decodestring from base64 import encodestring, decodestring
from multiprocessing import Process, Array from multiprocessing import Process, Array
from cloudooo.tests.handlerTestCase import HandlerTestCase, make_suite from cloudooo.tests.cloudoooTestCase import TestCase, make_suite
import magic import magic
DAEMON = True
mime_decoder = magic.Magic(mime=True) mime_decoder = magic.Magic(mime=True)
def basicTestToGenerate(id, proxy, data, source_format, destination_format, def basicTestToGenerate(id, proxy, data, source_format, destination_format,
result_list): result_list):
"""Test to use method generate of server""" """Test to use method generate of server"""
document = proxy.convertFile(data, source_format, destination_format) document = proxy.convertFile(encodestring(data), source_format, destination_format)
mimetype = mime_decoder.from_buffer(decodestring(document)) mimetype = mime_decoder.from_buffer(decodestring(document))
assert mimetype == 'application/pdf' assert mimetype == 'application/pdf'
result_list[id] = True result_list[id] = True
class TestHighLoad(HandlerTestCase): class TestHighLoad(TestCase):
"""Test with many simultaneous connection""" """Test with many simultaneous connection"""
def afterSetUp(self):
"""Creates connection with cloudooo Server"""
self.proxy = ServerProxy("http://%s:%s" % (self.hostname, self.cloudooo_port))
def testGenerateHighLoad(self): def testGenerateHighLoad(self):
"""Sends many request to Server. Calling generate method""" """Sends many request to Server. Calling generate method"""
process_list = [] process_list = []
data = encodestring(open("data/test.doc", 'r').read()) data = open("data/test.doc", 'r').read()
LOOP = 100 LOOP = 2
result_list = Array('i', [False] * LOOP) result_list = Array('i', [False] * LOOP)
for id in range(LOOP): for id in range(LOOP):
process = Process(target=basicTestToGenerate, args=(id, self.proxy, data, process = Process(target=basicTestToGenerate, args=(id, self.proxy, data,
......
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