Commit fa7ed25b authored by Jérome Perrin's avatar Jérome Perrin

test: use assertIsInstance

This does not need the types module which no longer exist
parent 2c7959c0
......@@ -33,7 +33,6 @@ from time import sleep
from cloudooo.handler.ooo.application.openoffice import openoffice
from cloudooo.handler.ooo.monitor.memory import MonitorMemory
from psutil import Process
from types import IntType
OPENOFFICE = True
......@@ -94,7 +93,7 @@ class TestMonitorMemory(unittest.TestCase):
self.monitor = MonitorMemory(openoffice, 2, 400)
self.monitor.create_process()
self.assertTrue(hasattr(self.monitor, 'process'))
self.assertEqual(type(self.monitor.process), Process)
self.assertIsInstance(self.monitor.process, Process)
def testGetMemoryUsage(self):
"""Test memory usage"""
......@@ -105,6 +104,6 @@ class TestMonitorMemory(unittest.TestCase):
if not openoffice.status():
openoffice.start()
memory_usage_int = self.monitor.get_memory_usage()
self.assertEqual(type(memory_usage_int), IntType)
self.assertIsInstance(memory_usage_int, int)
......@@ -43,7 +43,7 @@ class TestOdfDocument(HandlerTestCase):
def testReceivedGoodFile(self):
"""Test if received path is from a good document returing an ZipFile"""
self.assertTrue(isinstance(self.oodocument._zipfile, ZipFile))
self.assertIsInstance(self.oodocument._zipfile, ZipFile)
def testGetContentXml(self):
"""Test if the getContentXml method returns the content.xml file"""
......@@ -63,7 +63,7 @@ class TestOdfDocument(HandlerTestCase):
def testParseContent(self):
"""Test if the _parsed_content attribute is the parsed content.xml"""
# XXX not sure it is good to store parsed document everytime
self.assertTrue(isinstance(self.oodocument.parsed_content, etree._Element))
self.assertIsInstance(self.oodocument.parsed_content, etree._Element)
self.assertTrue(self.oodocument.parsed_content.tag.endswith(
'document-content'))
......
......@@ -34,7 +34,6 @@ from os import remove
from base64 import encodestring, decodestring
from StringIO import StringIO
from lxml import etree
from types import DictType
from zipfile import ZipFile, is_zipfile
from cloudooo.tests.cloudoooTestCase import TestCase
from cloudooo.tests.backportUnittest import expectedFailure
......@@ -226,7 +225,7 @@ class TestGetMetadata(TestCase):
'application/vnd.oasis.opendocument.text')
response_code, response_dict, response_message = generate_result
self.assertEqual(response_code, 200)
self.assertEqual(type(response_dict), DictType)
self.assertIsInstance(response_dict, dict)
self.assertNotEqual(response_dict['data'], '')
self.assertEqual(response_dict['mime'], 'application/pdf')
......@@ -245,7 +244,7 @@ class TestGenerate(TestCase):
"application/vnd.oasis.opendocument.spreadsheet")
response_code, response_dict, response_message = generate_result
self.assertEqual(response_code, 200)
self.assertEqual(type(response_dict), DictType)
self.assertIsInstance(response_dict, dict)
self.assertNotEqual(response_dict['data'], '')
self.assertEqual(response_dict['mime'], 'application/zip')
output_url = join(self.tmp_url, "zip.zip")
......@@ -272,7 +271,7 @@ class TestGenerate(TestCase):
"application/vnd.oasis.opendocument.spreadsheet")
response_code, response_dict, response_message = generate_result
self.assertEqual(response_code, 200)
self.assertEqual(type(response_dict), DictType)
self.assertIsInstance(response_dict, dict)
self.assertNotEqual(response_dict['data'], '')
self.assertEqual(response_dict['mime'], 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')
......@@ -289,7 +288,7 @@ class TestGenerate(TestCase):
'application/vnd.oasis.opendocument.presentation')
response_code, response_dict, response_message = generate_result
self.assertEqual(response_code, 200)
self.assertEqual(type(response_dict), DictType)
self.assertIsInstance(response_dict, dict)
self.assertNotEqual(response_dict['data'], '')
self.assertEqual(response_dict['mime'], 'application/zip')
output_url = join(self.tmp_url, "zip.zip")
......@@ -323,7 +322,7 @@ class TestGenerate(TestCase):
'application/vnd.oasis.opendocument.presentation')
response_code, response_dict, response_message = generate_result
self.assertEqual(response_code, 200)
self.assertEqual(type(response_dict), DictType)
self.assertIsInstance(response_dict, dict)
self.assertNotEqual(response_dict['data'], '')
self.assertEqual(response_dict['mime'], 'application/zip')
output_url = join(self.tmp_url, "zip.zip")
......@@ -351,7 +350,7 @@ class TestGenerate(TestCase):
None, 'pdf', 'application/vnd.oasis.opendocument.text')
response_code, response_dict, response_message = generate_result
self.assertEqual(response_code, 402)
self.assertEqual(type(response_dict), DictType)
self.assertIsInstance(response_dict, dict)
self.assertEqual(response_dict, {})
self.assertTrue(response_message.startswith('Traceback'))
......
......@@ -31,7 +31,6 @@
from cloudooo.handler.pdf.handler import Handler
from cloudooo.tests.handlerTestCase import HandlerTestCase
from types import DictType
class TestHandler(HandlerTestCase):
......@@ -53,7 +52,7 @@ class TestHandler(HandlerTestCase):
pdf_document = f.read()
handler = Handler(self.tmp_url, pdf_document, "pdf", **self.kw)
metadata = handler.getMetadata()
self.assertEqual(type(metadata), DictType)
self.assertIsInstance(metadata, dict)
self.assertNotEqual(metadata, {})
self.assertEqual(metadata["title"], 'Free Cloud Alliance Presentation')
......
......@@ -33,7 +33,6 @@ from os import environ, path
from ConfigParser import ConfigParser
from xmlrpclib import ServerProxy, Fault
from magic import Magic
from types import DictType
from base64 import encodestring, decodestring
from cloudooo.tests import backportUnittest
......@@ -132,7 +131,7 @@ class TestCase(backportUnittest.TestCase):
response_code, response_dict, response_message = \
self.proxy.run_convert(filename, encodestring(data))
self.assertEqual(response_code, expected_response_code)
self.assertEqual(type(response_dict), DictType)
self.assertIsInstance(response_dict, dict)
if expected_response_code == 402:
self.assertEqual(response_dict, {})
self.assertTrue(response_message.endswith(expected_response_message),
......
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