Commit 6999afe9 authored by Jérome Perrin's avatar Jérome Perrin

Fix test failures after updating to zope.interface 5.2

See merge request !31
parents 78d15e09 952d74b0
Pipeline #23206 passed with stage
in 0 seconds
...@@ -89,7 +89,7 @@ class OpenOffice(Application): ...@@ -89,7 +89,7 @@ class OpenOffice(Application):
def loadSettings(self, hostname, port, path_run_dir, def loadSettings(self, hostname, port, path_run_dir,
office_binary_path, uno_path, default_language, office_binary_path, uno_path, default_language,
environment_dict=None, **kw): environment_dict=None, **kw):
"""Method to load the configuratio to control one OpenOffice Instance """Method to load the configuration to control one OpenOffice Instance
Keyword arguments: Keyword arguments:
office_path -- Full Path of the OOo executable. office_path -- Full Path of the OOo executable.
e.g office_binary_path='/opt/openoffice.org3/program' e.g office_binary_path='/opt/openoffice.org3/program'
......
...@@ -48,137 +48,57 @@ from cloudooo.interfaces.granulate import ITableGranulator, \ ...@@ -48,137 +48,57 @@ from cloudooo.interfaces.granulate import ITableGranulator, \
ITextGranulator ITextGranulator
from cloudooo.tests.backportUnittest import TestCase, expectedFailure from cloudooo.tests.backportUnittest import TestCase, expectedFailure
import zope.interface.verify
class TestInterface(TestCase): class TestInterface(TestCase):
"""Test All Interfaces""" """Test All Interfaces"""
def testITableGranulator(self): def testITableGranulator(self):
"""Test if Manager implements ITableGranulator""" """Test if Manager implements ITableGranulator"""
self.assertTrue(ITableGranulator.implementedBy(Manager)) zope.interface.verify.verifyClass(ITableGranulator, Manager)
method_list = ['getLineItemList',
'getTable',
'getTableItemList',
'getColumnItemList']
self.assertEquals(sorted(ITableGranulator.names()), sorted(method_list))
def testITextGranulator(self): def testITextGranulator(self):
"""Test if Manager implements ITextGranulator""" """Test if Manager implements ITextGranulator"""
self.assertTrue(ITextGranulator.implementedBy(Manager)) zope.interface.verify.verifyClass(ITextGranulator, Manager)
method_list = ['getChapterItemList',
'getParagraph',
'getChapterItem',
'getParagraphItemList']
self.assertEquals(ITextGranulator.names(), method_list)
def testIImageGranulator(self): def testIImageGranulator(self):
"""Test if Manager implements IImageGranulator""" """Test if Manager implements IImageGranulator"""
self.assertTrue(IImageGranulator.implementedBy(Manager)) zope.interface.verify.verifyClass(IImageGranulator, Manager)
method_list = ['getImageItemList', 'getImage']
self.assertEquals(IImageGranulator.names(), method_list)
def testIFile(self): def testIFile(self):
"""Test if FileSystemDocument implements IFile""" """Test if FileSystemDocument implements IFile"""
self.assertTrue(IFile.implementedBy(FileSystemDocument)) zope.interface.verify.verifyClass(IFile, FileSystemDocument)
def testIOdfDocument(self): def testIOdfDocument(self):
"""Test if OdfDocument implements IOdfDocument""" """Test if OdfDocument implements IOdfDocument"""
self.assertTrue(IOdfDocument.implementedBy(OdfDocument)) zope.interface.verify.verifyClass(IOdfDocument, OdfDocument)
method_list = ['getContentXml',
'parsed_content',
'source_format',
'getFile']
self.assertEquals(IOdfDocument.names(), method_list)
def testIFilter(self): def testIFilter(self):
"""Test if Filter implements IFile""" """Test if Filter implements IFile"""
self.assertTrue(IFilter.implementedBy(Filter)) zope.interface.verify.verifyClass(IFilter, Filter)
self.assertEquals(IFilter.names(), ['getLabel', 'getName', 'getSortIndex',
'isPreferred', 'getDocumentService', 'getExtension', 'getMimetype'])
# XXX Change at interfaces are not applied in real classes.
# This tests should be rewrited to test the real classes instead hardcore
# copy and paste information.
@expectedFailure @expectedFailure
def testIManager(self): def testIManager(self):
"""Test if Manager implements IManager""" """Test if Manager implements IManager"""
self.assertTrue(IManager.implementedBy(Manager)) zope.interface.verify.verifyClass(IManager, Manager)
method_list = ['convertFile',
'getFileMetadataItemList',
'updateFileMetadata',
'getAllowedExtensionList',
'granulateFile']
for method in method_list:
self.assertTrue(method in IManager.names())
self.assertEquals(len(method_list), len(IManager.names()))
self.assertEquals(IManager.get('convertFile').required, ('file',
'source_format', 'destination_format', 'zip', 'refresh'))
self.assertEquals(IManager.get('getAllowedExtensionList').required,
('request_dict',))
self.assertEquals(IManager.get('getFileMetadataItemList').required,
('file', 'source_format', 'base_document'))
self.assertEquals(IManager.get('updateFileMetadata').required,
('file', 'source_format', 'metadata_dict'))
# XXX Change at interfaces are not applied in real classes.
# This tests should be rewrited to test the real classes instead hardcore
# copy and paste information.
@expectedFailure @expectedFailure
def testIMimeMapper(self): def testIMimeMapper(self):
"""Test if Mimemapper implements IMimemapper.""" """Test if Mimemapper implements IMimemapper."""
method_list = ['getDocumentTypeDict', 'getFilterName', 'loadFilterList', zope.interface.verify.verifyClass(IMimemapper, MimeMapper)
'getFilterList', 'getAllowedExtensionList',
'isLoaded']
for method in method_list:
self.assertTrue(method in IMimemapper.names())
self.assertTrue(IMimemapper.implementedBy(MimeMapper))
self.assertEquals(len(method_list), len(IMimemapper.names()))
self.assertEquals(IMimemapper.get('getFilterName').required,
('extension', 'document_type'))
self.assertEquals(IMimemapper.get('loadFilterList').required, ())
self.assertEquals(IMimemapper.get('getFilterList').required, ('extension',))
self.assertEquals(IMimemapper.get('getDocumentTypeDict').required, ())
self.assertEquals(IMimemapper.get('getAllowedExtensionList').required,
("document_type",))
def testIMonitor(self): def testIMonitor(self):
"""Test if Monitors implements IMonitor""" """Test if Monitors implements IMonitor"""
self.assertTrue(IMonitor.implementedBy(MonitorRequest)) zope.interface.verify.verifyClass(IMonitor, MonitorRequest)
self.assertEquals(IMonitor.names(), ["run"])
# XXX Change at interfaces are not applied in real classes.
# This tests should be rewrited to test the real classes instead hardcore
# copy and paste information.
@expectedFailure
def testIHandler(self): def testIHandler(self):
"""Test if Handlers implements IHandler""" """Test if Handlers implements IHandler"""
self.assertTrue(IHandler.implementedBy(Handler)) zope.interface.verify.verifyClass(IHandler, Handler)
method_list = ['convert', 'getMetadata', 'setMetadata']
for method in method_list:
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,
('converted_data',))
self.assertEquals(IHandler.get('setMetadata').required,
('metadata_dict',))
def testIApplication(self): def testIApplication(self):
"""Test if OpenOffice implements IApplication""" """Test if OpenOffice implements IApplication"""
self.assertTrue(IApplication.implementedBy(OpenOffice)) zope.interface.verify.verifyClass(IApplication, OpenOffice)
application_method_list = ["start", "stop", "pid",
"status", "restart",
"loadSettings", "getAddress"]
self.assertEquals(sorted(IApplication.names()),
sorted(application_method_list))
def testILockable(self): def testILockable(self):
"""Test if Openoffice implements ILockable""" """Test if Openoffice implements ILockable"""
self.assertTrue(ILockable.implementedBy(OpenOffice)) zope.interface.verify.verifyClass(ILockable, OpenOffice)
lockable_method_list = ["_lock", "acquire", "release", "isLocked"]
self.assertEquals(sorted(ILockable.names()), sorted(lockable_method_list))
...@@ -45,10 +45,15 @@ class IApplication(Interface): ...@@ -45,10 +45,15 @@ class IApplication(Interface):
def pid(): def pid():
"""Get the process pid""" """Get the process pid"""
def loadSettings(hostname, def loadSettings(
port, hostname,
working_path, port,
office_binary_path): working_path,
office_binary_path,
uno_path,
default_language,
environment_dict=None,
):
"""Load configuration to control OOo Instances""" """Load configuration to control OOo Instances"""
def status(): def status():
......
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