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