Commit 11deccde authored by Gabriel Monnerat's avatar Gabriel Monnerat

clean up the code to follow PEP08

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk/utils@43709 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 7c494df9
......@@ -86,4 +86,3 @@ class FFMPEGHandler(object):
metadata -- expected an dictionary with metadata.
"""
raise NotImplementedError
......@@ -33,6 +33,7 @@ from cloudooo.handler.tests.handlerTestCase import HandlerTestCase, make_suite
file_detector = Magic(mime=True)
class TestAllFormats(HandlerTestCase):
def afterSetUp(self):
......@@ -46,8 +47,8 @@ class TestAllFormats(HandlerTestCase):
output = FFMPEGHandler(self.tmp_url, output_data, "avi")
input_data = output.convert("ogv")
input_format = file_detector.from_buffer(input_data)
self.assertTrue((output_format ==('video/avi')) and
(input_format == 'video/ogg'))
self.assertEquals(output_format, 'video/avi')
self.assertEquals(input_format, 'video/ogg')
def testMp4Format(self):
"""Test convert file to mp4 format the reverse convertion"""
......@@ -56,8 +57,8 @@ class TestAllFormats(HandlerTestCase):
output = FFMPEGHandler(self.tmp_url, output_data, "mp4")
input_data = output.convert("ogv")
input_format = file_detector.from_buffer(input_data)
self.assertTrue((output_format == 'video/mp4') and
(input_format == 'video/ogg'))
self.assertEquals(output_format, 'video/mp4')
self.assertEquals(input_format, 'video/ogg')
def testWebMFormat(self):
"""Test convert file to WebM format and the reverse convertion"""
......@@ -66,8 +67,8 @@ class TestAllFormats(HandlerTestCase):
output = FFMPEGHandler(self.tmp_url, output_data, "webm")
input_data = output.convert("ogv")
input_format = file_detector.from_buffer(input_data)
self.assertTrue((output_format == 'video/webm') and
(input_format == 'video/ogg'))
self.assertEquals(output_format, 'video/webm')
self.assertEquals(input_format, 'video/ogg')
def testFlvFormat(self):
"""Test convert file to flash format the reverse convertion"""
......@@ -76,8 +77,8 @@ class TestAllFormats(HandlerTestCase):
output = FFMPEGHandler(self.tmp_url, output_data, "flv")
input_data = output.convert("ogv")
input_format = file_detector.from_buffer(input_data)
self.assertTrue((output_format == 'application/x-shockwave-flash') and
(input_format == 'video/ogg'))
self.assertEquals(output_format, 'application/x-shockwave-flash')
self.assertEquals(input_format, 'video/ogg')
def testMpegFormat(self):
"""Test convert file to Mpeg format the reverse convertion"""
......@@ -86,8 +87,8 @@ class TestAllFormats(HandlerTestCase):
output = FFMPEGHandler(self.tmp_url, output_data, "mpeg")
input_data = output.convert("ogv")
input_format = file_detector.from_buffer(input_data)
self.assertTrue((output_format == 'video/mpeg') and
(input_format == 'video/ogg'))
self.assertEquals(output_format, 'video/mpeg')
self.assertEquals(input_format, 'video/ogg')
def testMkvFormat(self):
"""Test convert file to matroska format the reverse convertion"""
......@@ -96,8 +97,8 @@ class TestAllFormats(HandlerTestCase):
output = FFMPEGHandler(self.tmp_url, output_data, "mkv")
input_data = output.convert("ogv")
input_format = file_detector.from_buffer(input_data)
self.assertTrue((output_format == 'video/x-matroska') and
(input_format == 'video/ogg'))
self.assertEquals(output_format, 'video/x-matroska')
self.assertEquals(input_format, 'video/ogg')
def testOggFormat(self):
"""Test convert file to ogg format the reverse convertion"""
......@@ -106,8 +107,8 @@ class TestAllFormats(HandlerTestCase):
output = FFMPEGHandler(self.tmp_url, output_data, "ogg")
input_data = output.convert("ogv")
input_format = file_detector.from_buffer(input_data)
self.assertTrue((output_format == 'aplication/ogg') and
(input_format == 'video/ogg'))
self.assertEquals(output_format, 'application/ogg')
self.assertEquals(input_format, 'video/ogg')
def test_suite():
......
......@@ -31,6 +31,7 @@ from cloudooo.interfaces.handler import IHandler
from cloudooo.handler.ffmpeg.handler import FFMPEGHandler
from cloudooo.handler.tests.handlerTestCase import make_suite
class TestInterface(unittest.TestCase):
"""Test IHandler Interface"""
......@@ -42,8 +43,3 @@ class TestInterface(unittest.TestCase):
def test_suite():
return make_suite(TestInterface)
if __name__ == "__main__":
suite = unittest.TestLoader().loadTestsFromTestCase(TestInterface)
unittest.TextTestRunner(verbosity=2).run(suite)
......@@ -60,7 +60,5 @@ class TestServer(HandlerTestCase):
"""Test if metadata is inserted correctly"""
def test_suite():
return make_suite(TestServer)
......@@ -29,5 +29,6 @@
from cloudooo.handler.tests import runHandlerUnitTest
def run():
runHandlerUnitTest.run("imagemagick")
......@@ -29,5 +29,6 @@
from cloudooo.handler.tests import runHandlerUnitTest
def run():
runHandlerUnitTest.run("ooo")
......@@ -48,6 +48,7 @@ from cloudooo.interfaces.granulate import ITableGranulator, \
ITextGranulator
from cloudooo.handler.tests.handlerTestCase import make_suite
class TestInterface(unittest.TestCase):
"""Test All Interfaces"""
......@@ -172,7 +173,3 @@ class TestInterface(unittest.TestCase):
def test_suite():
return make_suite(TestInterface)
if __name__ == "__main__":
suite = unittest.TestLoader().loadTestsFromTestCase(TestInterface)
unittest.TextTestRunner(verbosity=2).run(suite)
......@@ -82,7 +82,6 @@ class TestOOGranulator(HandlerTestCase):
table_data = oogranulator.getTableItem('NonExistentTable')
self.assertEquals(table_data, None)
def testGetColumnItemList(self):
"""Test if getColumnItemList() returns the right table columns list"""
self.assertRaises(NotImplementedError, self.oogranulator.getColumnItemList,
......@@ -180,5 +179,6 @@ class TestOOGranulator(HandlerTestCase):
self.assertRaises(NotImplementedError, self.oogranulator.getChapterItem,
'chapter_id')
def test_suite():
return make_suite(TestOOGranulator)
......@@ -591,7 +591,7 @@ class TestServer(HandlerTestCase):
'P5'], [15, 'P5'], [16, 'P14'], [17, 'P11'], [18, 'P11'],
[19, 'Standard'], [20, 'P2'], [21, 'P2'], [22, 'P2'],
[23, 'P2'], [24, 'P2'], [25, 'P2'], [26, 'P2'], [27,
'P2'], [28, 'P2'], [29, 'P2']],paragraph_list)
'P2'], [28, 'P2'], [29, 'P2']], paragraph_list)
def testGetParagraphItem(self):
"""Test if manager can get a paragraph"""
......@@ -612,5 +612,6 @@ class TestServer(HandlerTestCase):
self.assertRaises(Fault, self.proxy.getChapterItem, ("id", data, "odt"))
def test_suite():
return make_suite(TestServer)
......@@ -33,6 +33,7 @@ from cloudooo.utils.utils import logger, configureLogger, \
from cloudooo.handler.tests.handlerTestCase import make_suite
import mimetypes
class TestUtils(unittest.TestCase):
"""Test Utils"""
......
......@@ -43,6 +43,7 @@ def make_suite(test_case):
suite.addTest(unittest.makeSuite(test_case))
return suite
def check_folder(working_path, tmp_dir_path):
if not path.exists(working_path):
mkdir(working_path)
......@@ -102,6 +103,7 @@ def stopFakeEnvironment(stop_openoffice=True):
openoffice.stop()
return True
class HandlerTestCase(unittest.TestCase):
"""Test Case to load cloudooo conf."""
......
......@@ -54,7 +54,8 @@ class IImageGranulator(Interface):
def getImageItemList(data, source_format):
"""Return the list of images in the form of (id, title)."""
def getImage(data, image_id, source_format, format=None, resolution=None, **kw):
def getImage(data, image_id, source_format,
format=None, resolution=None, **kw):
"""Return the given image."""
......
......@@ -70,7 +70,6 @@ class Manager(object):
implements(IManager, IERP5Compatibility, ITableGranulator, IImageGranulator,
ITextGranulator)
def __init__(self, path_tmp_dir, **kw):
"""Need pass the path where the temporary document will be created."""
self._path_tmp_dir = path_tmp_dir
......
......@@ -51,7 +51,7 @@ PYTHON_ENVIRONMENT = [
def loadMimetypeList():
mime_types_url = pkg_resources.resource_filename("cloudooo",
"mime.types")
mimetypes.init(files=[mime_types_url,])
mimetypes.init(files=[mime_types_url, ])
def configureLogger(level=None, debug_mode=False):
......
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