Commit f013ec03 authored by Priscila Manhaes's avatar Priscila Manhaes

refator to use cloudoootestcase

parent 3aecbb02
...@@ -26,69 +26,42 @@ ...@@ -26,69 +26,42 @@
# #
############################################################################## ##############################################################################
from xmlrpclib import ServerProxy, Fault from cloudooo.tests.cloudoooTestCase import TestCase, make_suite
from base64 import encodestring, decodestring
from cloudooo.tests.handlerTestCase import HandlerTestCase, make_suite
import magic
file_detector = magic.Magic() class TestAllFormats(TestCase):
DAEMON = True
class TestAllFormats(HandlerTestCase):
"""Test XmlRpc Server. Needs cloudooo server started""" """Test XmlRpc Server. Needs cloudooo server started"""
def afterSetUp(self):
"""Create connection with cloudooo server"""
self.proxy = ServerProxy("http://%s:%s/RPC2" % (self.hostname,
self.cloudooo_port))
def testTextFormats(self): def testTextFormats(self):
"""Test all text formats""" """Test all text formats"""
self.runTestForType('odt', 'text', 'data/test.odt') self.runTestForType('data/test.odt', 'odt', 'text')
def testPresentationFormats(self): def testPresentationFormats(self):
"""Test all presentation formats""" """Test all presentation formats"""
self.runTestForType('odp', 'presentation', 'data/test.odp') self.runTestForType('data/test.odp', 'odp', 'presentation')
def testDrawingFormats(self): def testDrawingFormats(self):
"""Test all drawing formats""" """Test all drawing formats"""
self.runTestForType('odg', 'drawing', 'data/test.odg') self.runTestForType('data/test.odg', 'odg', 'drawing')
def testSpreadSheetFormats(self): def testSpreadSheetFormats(self):
"""Test all spreadsheet formats""" """Test all spreadsheet formats"""
self.runTestForType('ods', 'spreadsheet', 'data/test.ods') self.runTestForType('data/test.ods', 'ods', 'spreadsheet')
def testWebFormats(self): def testWebFormats(self):
"""Test all web formats""" """Test all web formats"""
self.runTestForType('html', 'web', 'data/test.html') self.runTestForType('data/test.html', 'html', 'web')
def testGlobalFormats(self): def testGlobalFormats(self):
"""Test all global formats""" """Test all global formats"""
self.runTestForType('sxg', 'global', 'data/test.sxg') self.runTestForType('data/test.sxg', 'sxg', 'global')
def runTestForType(self, source_format, document_type, filename): def runTestForType(self, input_url, source_format, document_type):
"""Generic test""" """Generic test for converting all formats"""
data = open(filename, 'r').read()
request = {'document_type': document_type} request = {'document_type': document_type}
extension_list = self.proxy.getAllowedExtensionList(request) extension_list = self.proxy.getAllowedExtensionList(request)
fault_list = [] fault_list = []
for extension in extension_list: for extension in extension_list:
try: self._testConvertFile(input_url, source_format, extension[0], None)
data_output = self.proxy.convertFile(encodestring(data),
source_format,
extension[0])
magic_result = file_detector.from_buffer(decodestring(data_output))
file_is_empty = magic_result.endswith(": empty")
if file_is_empty:
fault_list.append((source_format, extension[0], magic_result))
except Fault, err:
fault_list.append((source_format, extension[0], err.faultString))
if fault_list:
template_message = 'input_format: %r\noutput_format: %r\n traceback:\n%s'
message = '\n'.join([template_message % fault for fault in fault_list])
self.fail('Failed Conversions:\n' + message)
def test_suite(): def test_suite():
return make_suite(TestAllFormats) return make_suite(TestAllFormats)
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