Commit f530b4ce authored by Priscila Manhaes's avatar Priscila Manhaes

refactor to cloudoootestcase

parent 60dda98b
...@@ -26,61 +26,41 @@ ...@@ -26,61 +26,41 @@
# #
############################################################################## ##############################################################################
from xmlrpclib import ServerProxy
from base64 import encodestring, decodestring from base64 import encodestring, decodestring
from cloudooo.tests.handlerTestCase import HandlerTestCase, make_suite from cloudooo.tests.cloudoooTestCase import TestCase, make_suite
import magic
from pkg_resources import resource_filename from pkg_resources import resource_filename
file_detector = magic.Magic(mime=True)
DAEMON = True
class TestLegacyInterface(HandlerTestCase): class TestLegacyInterface(TestCase):
def afterSetUp(self):
"""Create connection with cloudooo server"""
self.proxy = ServerProxy("http://%s:%s/RPC2" % (self.hostname,
self.cloudooo_port),
allow_none=True)
def testHtmlToBaseFormatConversion(self): def testHtmlToBaseFormatConversion(self):
"""Check implicit base conversion of HTML documents. """Check implicit base conversion of HTML documents."""
"""
filename = resource_filename('cloudooo.handler.ooo.tests.data', filename = resource_filename('cloudooo.handler.ooo.tests.data',
'test_failure_conversion.html') 'test_failure_conversion.html')
file_object = open(filename, 'r') data = open(filename, 'r').read()
original_data = file_object.read()
file_object.close()
status, response_dict, message = self.proxy.run_convert( status, response_dict, message = self.proxy.run_convert(
filename, filename,
encodestring(original_data), encodestring(data),
None, None,
None, None,
'text/html') 'text/html')
converted_data = response_dict['data'] self.assertEquals(self._getFileType(decodestring(response_dict['data'])),
mimetype = response_dict['mime']
self.assertEquals(file_detector.from_buffer(decodestring(converted_data)),
'text/html') 'text/html')
self.assertEquals(mimetype, 'text/html') self.assertEquals(response_dict['mime'], 'text/html')
def testHtmlToOdt(self): def testHtmlToOdt(self):
"""Check conversion of HTML to odt """Check conversion of HTML to odt"""
"""
filename = resource_filename('cloudooo.handler.ooo.tests.data', filename = resource_filename('cloudooo.handler.ooo.tests.data',
'test_failure_conversion.html') 'test_failure_conversion.html')
file_object = open(filename, 'r') data = open(filename, 'r').read()
data = file_object.read()
file_object.close()
status, response_dict, message = self.proxy.run_generate(filename, status, response_dict, message = self.proxy.run_generate(filename,
encodestring(data), encodestring(data),
None, None,
'odt', 'odt',
'text/html') 'text/html')
data = response_dict['data'] self.assertEquals(self._getFileType(decodestring(response_dict['data'])),
mimetype = response_dict['mime']
self.assertEquals(file_detector.from_buffer(decodestring(data)),
'application/vnd.oasis.opendocument.text') 'application/vnd.oasis.opendocument.text')
self.assertEquals(mimetype, 'application/vnd.oasis.opendocument.text') self.assertEquals(response_dict['mime'], 'application/vnd.oasis.opendocument.text')
def test_suite(): def test_suite():
return make_suite(TestLegacyInterface) return make_suite(TestLegacyInterface)
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