Commit 1963d1a2 authored by Gabriel Monnerat's avatar Gabriel Monnerat

use boolean asserts to validate True or False

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk/utils@42041 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent f30a552f
......@@ -66,7 +66,7 @@ class TestFileSystemDocument(unittest.TestCase):
self.fsdocument.restoreOriginal()
self.assertEquals(path.exists(old_document_url), False)
self.assertNotEquals(old_document_url, self.fsdocument.getUrl())
self.assertEquals(path.exists(self.fsdocument.getUrl()), True)
self.assertTrue(path.exists(self.fsdocument.getUrl()))
self.assertEquals(self.fsdocument.getContent(), self.data)
def testgetContent(self):
......@@ -76,7 +76,7 @@ class TestFileSystemDocument(unittest.TestCase):
def testgetUrl(self):
"""Check if the url is correct"""
url = self.fsdocument.getUrl()
self.assertEquals(path.exists(url), True)
self.assertTrue(path.exists(url))
def testLoadDocumentFile(self):
"""Test if the document is created correctly"""
......@@ -126,7 +126,7 @@ class TestFileSystemDocument(unittest.TestCase):
data = open(zip_input_url).read()
zipdocument = FileSystemDocument(self.tmp_url, data, 'zip')
open(zip_output_url, 'w').write(zipdocument.getContent(True))
self.assertEquals(is_zipfile(zip_output_url), True)
self.assertTrue(is_zipfile(zip_output_url))
zipfile = ZipFile(zip_output_url)
self.assertEquals(sorted(zipfile.namelist()),
sorted(['logo.gif', 'test.htm']))
......
......@@ -51,7 +51,7 @@ class TestFilter(unittest.TestCase):
self.assertEquals(self.filter.getName(), 'writer_pdf_Export')
self.assertEquals(self.filter.getMimetype(), 'application/pdf')
self.assertEquals(self.filter.getSortIndex(), 1000)
self.assertEquals(self.filter.isPreferred(), True)
self.assertTrue(self.filter.isPreferred())
def test_suite():
......
......@@ -55,7 +55,7 @@ class TestInterface(unittest.TestCase):
def testITableGranulator(self):
"""Test if OOGranulator implements ITableGranulator"""
self.assertEquals(ITableGranulator.implementedBy(OOGranulator), True)
self.assertTrue(ITableGranulator.implementedBy(OOGranulator))
method_list = ['getLineItemList',
'getTableItem',
'getTableItemList',
......@@ -65,7 +65,7 @@ class TestInterface(unittest.TestCase):
def testITextGranulator(self):
"""Test if OOGranulator implements ITextGranulator"""
self.assertEquals(ITextGranulator.implementedBy(OOGranulator), True)
self.assertTrue(ITextGranulator.implementedBy(OOGranulator))
method_list = ['getChapterItemList',
'getParagraphItem',
'getChapterItem',
......@@ -74,17 +74,17 @@ class TestInterface(unittest.TestCase):
def testIImageGranulator(self):
"""Test if OOGranulator implements IImageGranulator"""
self.assertEquals(IImageGranulator.implementedBy(OOGranulator), True)
self.assertTrue(IImageGranulator.implementedBy(OOGranulator))
method_list = ['getImageItemList', 'getImage']
self.assertEquals(IImageGranulator.names(), method_list)
def testIDocument(self):
"""Test if FileSystemDocument implements IDocument"""
self.assertEquals(IDocument.implementedBy(FileSystemDocument), True)
self.assertTrue(IDocument.implementedBy(FileSystemDocument))
def testIOdfDocument(self):
"""Test if OdfDocument implements IOdfDocument"""
self.assertEquals(IOdfDocument.implementedBy(OdfDocument), True)
self.assertTrue(IOdfDocument.implementedBy(OdfDocument))
method_list = ['getContentXml',
'parsed_content',
'source_format',
......@@ -93,13 +93,13 @@ class TestInterface(unittest.TestCase):
def testIFilter(self):
"""Test if Filter implements IDocument"""
self.assertEquals(IFilter.implementedBy(Filter), True)
self.assertTrue(IFilter.implementedBy(Filter))
self.assertEquals(IFilter.names(), ['getLabel', 'getName', 'getSortIndex',
'isPreferred', 'getDocumentService', 'getExtension', 'getMimetype'])
def testIManager(self):
"""Test if Manager implements IManager"""
self.assertEquals(IManager.implementedBy(Manager), True)
self.assertTrue(IManager.implementedBy(Manager))
method_list = ['convertFile',
'getFileMetadataItemList',
'updateFileMetadata',
......@@ -107,7 +107,7 @@ class TestInterface(unittest.TestCase):
'granulateFile']
for method in method_list:
self.assertEquals(method in IManager.names(), True)
self.assertTrue(method in IManager.names())
self.assertEquals(len(method_list), len(IManager.names()))
self.assertEquals(IManager.get('convertFile').required, ('file',
......@@ -125,9 +125,9 @@ class TestInterface(unittest.TestCase):
'getFilterList', 'getAllowedExtensionList', 'getMimetypeByFilterType',
'isLoaded']
for method in method_list:
self.assertEquals(method in IMimemapper.names(), True)
self.assertTrue(method in IMimemapper.names())
self.assertEquals(IMimemapper.implementedBy(MimeMapper), True)
self.assertTrue(IMimemapper.implementedBy(MimeMapper))
self.assertEquals(len(method_list), len(IMimemapper.names()))
self.assertEquals(IMimemapper.get('getFilterName').required,
('extension', 'document_type'))
......@@ -141,16 +141,16 @@ class TestInterface(unittest.TestCase):
def testIMonitor(self):
"""Test if Monitors implements IMonitor"""
self.assertEquals(IMonitor.implementedBy(MonitorRequest), True)
self.assertTrue(IMonitor.implementedBy(MonitorRequest))
self.assertEquals(IMonitor.names(), ["run"])
def testIHandler(self):
"""Test if Handlers implements IHandler"""
self.assertEquals(IHandler.implementedBy(OOHandler), True)
self.assertTrue(IHandler.implementedBy(OOHandler))
method_list = ['convert', 'getMetadata', 'setMetadata']
for method in method_list:
self.assertEquals(method in IHandler.names(), True,
"Method %s is not declared" % method)
self.assertTrue(method in IHandler.names(),
"Method %s is not declared" % method)
self.assertEquals(len(method_list), len(IHandler.names()))
self.assertEquals(IHandler.get('convert').required, ('destination_format',))
self.assertEquals(IHandler.get('getMetadata').required,
......@@ -160,8 +160,8 @@ class TestInterface(unittest.TestCase):
def testIApplication(self):
"""Test if OpenOffice implements IApplication"""
self.assertEquals(IApplication.implementedBy(OpenOffice), True)
self.assertEquals(IApplication.implementedBy(Xvfb), True)
self.assertTrue(IApplication.implementedBy(OpenOffice))
self.assertTrue(IApplication.implementedBy(Xvfb))
application_method_list = ["start", "stop", "pid",
"status", "restart",
"loadSettings", "getAddress"]
......@@ -170,7 +170,7 @@ class TestInterface(unittest.TestCase):
def testILockable(self):
"""Test if Openoffice implements ILockable"""
self.assertEquals(ILockable.implementedBy(OpenOffice), True)
self.assertTrue(ILockable.implementedBy(OpenOffice))
lockable_method_list = ["_lock", "acquire", "release", "isLocked"]
self.assertEquals(sorted(ILockable.names()), sorted(lockable_method_list))
......
......@@ -60,7 +60,7 @@ class TestMonitorMemory(unittest.TestCase):
self.monitor = MonitorMemory(openoffice, 1, 1000)
self.monitor.start()
sleep(6)
self.assertEquals(openoffice.status(), True)
self.assertTrue(openoffice.status())
finally:
self.monitor.terminate()
......@@ -82,7 +82,7 @@ class TestMonitorMemory(unittest.TestCase):
self.monitor.start()
try:
sleep(self.interval)
self.assertEquals(self.monitor.is_alive(), True)
self.assertTrue(self.monitor.is_alive())
finally:
self.monitor.terminate()
......@@ -90,7 +90,7 @@ class TestMonitorMemory(unittest.TestCase):
"""Test if the psutil.Process is create correctly"""
self.monitor = MonitorMemory(openoffice, 2, 1000)
self.monitor.create_process()
self.assertEquals(hasattr(self.monitor, 'process'), True)
self.assertTrue(hasattr(self.monitor, 'process'))
self.assertEquals(type(self.monitor.process), Process)
def testGetMemoryUsage(self):
......
......@@ -40,7 +40,7 @@ class TestMonitorRequest(cloudoooTestCase):
"""Test terminate function to stop the thread"""
monitor_request = MonitorRequest(openoffice, 0, 2)
monitor_request.start()
self.assertEquals(monitor_request.is_alive(), True)
self.assertTrue(monitor_request.is_alive())
monitor_request.terminate()
sleep(4)
try:
......
......@@ -44,7 +44,7 @@ class TestMonitorTimeout(unittest.TestCase):
"""Test if the monitor of memory works"""
monitor_timeout = self._createMonitor(10)
monitor_timeout.start()
self.assertEquals(monitor_timeout.is_alive(), True)
self.assertTrue(monitor_timeout.is_alive())
monitor_timeout.terminate()
monitor_timeout = self._createMonitor(1)
monitor_timeout.start()
......@@ -61,7 +61,7 @@ class TestMonitorTimeout(unittest.TestCase):
sleep(2)
self.assertEquals(openoffice.status(), False)
openoffice.restart()
self.assertEquals(openoffice.status(), True)
self.assertTrue(openoffice.status())
finally:
monitor_timeout.terminate()
openoffice.release()
......@@ -76,7 +76,7 @@ class TestMonitorTimeout(unittest.TestCase):
self.assertEquals(openoffice.status(), False)
monitor_timeout.terminate()
openoffice.restart()
self.assertEquals(openoffice.status(), True)
self.assertTrue(openoffice.status())
monitor_timeout = self._createMonitor(1)
monitor_timeout.start()
sleep(2)
......
......@@ -102,7 +102,7 @@ class TestOOHandler(cloudoooTestCase):
'odt')
metadata = handler.getMetadata()
self.assertEquals(metadata.get('Data'), '')
self.assertEquals(metadata.has_key('Data'), True)
self.assertTrue(metadata.has_key('Data'))
self.assertEquals(metadata.get('MIMEType'),
'application/vnd.oasis.opendocument.text')
handler.document.restoreOriginal()
......
......@@ -31,7 +31,6 @@ from cloudoooTestCase import cloudoooTestCase
from cloudooo.handler.ooo.application.openoffice import OpenOffice
from cloudoooTestCase import make_suite
from cloudooo.handler.ooo.utils.utils import waitStopDaemon
from psutil import Process, AccessDenied
class TestOpenOffice(cloudoooTestCase):
......@@ -62,7 +61,7 @@ class TestOpenOffice(cloudoooTestCase):
def testOpenOfficeStart(self):
"""Test if the start method works correclty"""
self.assertEquals(self.openoffice.status(), True)
self.assertTrue(self.openoffice.status())
def testOpenOfficeStop(self):
"""Test if the stop method works correctly"""
......@@ -79,12 +78,12 @@ class TestOpenOffice(cloudoooTestCase):
def testOpenOfficeRestart(self):
"""Test if the method restart works correctly"""
self.openoffice.restart()
self.assertEquals(self.openoffice.status(), True)
self.assertTrue(self.openoffice.status())
def testOpenOfficeLock(self):
"""Test lock and unlock"""
self.openoffice.acquire()
self.assertEquals(self.openoffice.isLocked(), True)
self.assertTrue(self.openoffice.isLocked())
self.openoffice.release()
self.assertEquals(self.openoffice.isLocked(), False)
......@@ -100,7 +99,7 @@ class TestOpenOffice(cloudoooTestCase):
'en')
second_openoffice.start()
self.assertEquals(self.openoffice.status(), False)
self.assertEquals(second_openoffice.status(), True)
self.assertTrue(second_openoffice.status())
second_openoffice.stop()
self.openoffice.start()
......@@ -112,8 +111,8 @@ class TestOpenOffice(cloudoooTestCase):
self.uno_path,
'en')
second_openoffice.start()
self.assertEquals(self.openoffice.status(), True)
self.assertEquals(second_openoffice.status(), True)
self.assertTrue(self.openoffice.status())
self.assertTrue(second_openoffice.status())
def test_suite():
......
......@@ -278,7 +278,7 @@ class TestServer(cloudoooTestCase):
'txt',
'ASCII text\n')
self.assertEquals(open(output_url).read().endswith('cloudooo Test\n \n'), True)
self.assertTrue(open(output_url).read().endswith('cloudooo Test\n \n'))
def testConvertPNGToSVG(self):
"""Test export png to svg"""
......@@ -323,8 +323,8 @@ class TestServer(cloudoooTestCase):
self.fail(fail_msg)
except Fault, err:
msg = "This format is not supported or is invalid"
self.assertEquals(err.faultString.endswith(msg), True,
"ConvertFile\n" + err.faultString)
self.assertTrue(err.faultString.endswith(msg),
"ConvertFile\n" + err.faultString)
res = self.proxy.getFileMetadataItemList(data, '')
self.assertEquals(res['MIMEType'], "text/plain")
......@@ -341,8 +341,8 @@ class TestServer(cloudoooTestCase):
self.fail("")
except Fault, err:
err_str = err.faultString
self.assertEquals(err_str.endswith(error_msg), True,
"%s\n%s" % (error_msg, err_str))
self.assertTrue(err_str.endswith(error_msg),
"%s\n%s" % (error_msg, err_str))
def testConvertDocumentToImpossibleFormat(self):
"""Try convert one document to format not possible"""
......@@ -352,7 +352,7 @@ class TestServer(cloudoooTestCase):
self.fail("")
except Fault, err:
err_str = err.faultString
self.assertEquals(err_str.endswith("ErrorCodeIOException\n"), True)
self.assertTrue(err_str.endswith("ErrorCodeIOException\n"))
def testRunConvertMethod(self):
"""Test run_convert method"""
......@@ -439,7 +439,7 @@ class TestServer(cloudoooTestCase):
zipfile.extractall(self.tmp_url)
stdout, stderr = Popen("file -b %s" % png_path, shell=True,
stdout=PIPE).communicate()
self.assertEquals(stdout.startswith('PNG image data'), True, stdout)
self.assertTrue(stdout.startswith('PNG image data'), stdout)
self.assertTrue("8-bit/color RGB" in stdout, stdout)
finally:
zipfile.close()
......@@ -479,7 +479,7 @@ class TestServer(cloudoooTestCase):
self.assertEquals(response_code, 402)
self.assertEquals(type(response_dict), DictType)
self.assertEquals(response_dict, {})
self.assertEquals(response_message.startswith('Traceback'), True)
self.assertTrue(response_message.startswith('Traceback'))
def testRunSetMetadata(self):
"""Test run_setmetadata method"""
......@@ -518,7 +518,7 @@ class TestServer(cloudoooTestCase):
response_code, response_dict, response_message = setmetadata_result
self.assertEquals(response_code, 402)
self.assertEquals(response_dict, {})
self.assertEquals(response_message.startswith('Traceback'), True)
self.assertTrue(response_message.startswith('Traceback'))
def testGetAllowedTargetItemList(self):
"""Test if filter name returns correctly with ERP5 API"""
......
......@@ -77,7 +77,7 @@ class TestUnoConverter(cloudoooTestCase):
stdout=PIPE, stderr=PIPE).communicate()
self.assertEquals(stderr, '')
output_url = stdout.replace('\n', '')
self.assertEquals(exists(output_url), True, stdout)
self.assertTrue(exists(output_url), stdout)
stdout, stderr = Popen("file %s" % output_url, shell=True,
stdout=PIPE, stderr=PIPE).communicate()
self.assertEquals(self.file_msg_list[1] in stdout \
......
......@@ -65,8 +65,8 @@ class TestUnoMimeMapper(cloudoooTestCase):
stdout=PIPE, stderr=PIPE).communicate()
self.assertEquals(stderr, '')
filter_dict, type_dict = json.loads(stdout)
self.assertEquals('filter_dict' in locals(), True)
self.assertEquals('type_dict' in locals(), True)
self.assertTrue('filter_dict' in locals())
self.assertTrue('type_dict' in locals())
self.assertNotEquals(filter_dict.get('writer8'), None)
self.assertEquals(type_dict.get('writer8').get('Name'), 'writer8')
self.assertNotEquals(filter_dict.get('writer8'), None)
......@@ -85,8 +85,8 @@ class TestUnoMimeMapper(cloudoooTestCase):
stdout=PIPE, stderr=PIPE).communicate()
self.assertEquals(stderr, '')
filter_dict, type_dict = json.loads(stdout)
self.assertEquals('filter_dict' in locals(), True)
self.assertEquals('type_dict' in locals(), True)
self.assertTrue('filter_dict' in locals())
self.assertTrue('type_dict' in locals())
self.assertNotEquals(filter_dict.get('writer8'), None)
self.assertEquals(type_dict.get('writer8').get('Name'), 'writer8')
self.assertNotEquals(filter_dict.get('writer8'), None)
......@@ -109,7 +109,7 @@ class TestUnoMimeMapper(cloudoooTestCase):
stdout, stderr = Popen(' '.join(command), shell=True,
stdout=PIPE, stderr=PIPE).communicate()
self.assertEquals(stdout, '')
self.assertEquals(stderr.endswith(error_msg), True, stderr)
self.assertTrue(stderr.endswith(error_msg), stderr)
openoffice.start()
......
......@@ -47,9 +47,9 @@ class TestUtils(unittest.TestCase):
def testConversion(self):
"""Test convertion to bool"""
self.assertEquals(convertStringToBool('true'), True)
self.assertTrue(convertStringToBool('true'))
self.assertEquals(convertStringToBool('false'), False)
self.assertEquals(convertStringToBool('truE'), True)
self.assertTrue(convertStringToBool('truE'))
self.assertEquals(convertStringToBool('faLse'), False)
self.assertEquals(convertStringToBool(''), None)
......
......@@ -48,21 +48,21 @@ class TestXvfb(cloudoooTestCase):
self.assertEquals(self.xvfb.pid(), None)
self.xvfb.start()
self.assertNotEquals(self.xvfb.pid(), None)
self.assertEquals(self.xvfb.status(), True)
self.assertTrue(self.xvfb.status())
self.xvfb.stop()
self.assertNotEquals(self.xvfb.pid(), None)
self.assertEquals(self.xvfb.status(), False)
def testStatus(self):
"""Test if xvfb is started and stopped correctly"""
self.assertEquals(self.xvfb.status(), False)
self.assertFalse(self.xvfb.status())
try:
self.xvfb.start()
self.assertEquals(self.xvfb.status(), True)
self.assertTrue(self.xvfb.status())
finally:
self.xvfb.stop()
waitStopDaemon(self.xvfb)
self.assertEquals(self.xvfb.status(), False)
self.assertFalse(self.xvfb.status())
def test_suite():
......
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