Changeset 1478 in products


Ignore:
Timestamp:
Dec 25, 2009 2:24:31 PM (14 years ago)
Author:
mylan
Message:

Added tests for importmanager section

Location:
quintagroup.transmogrifier/trunk/quintagroup/transmogrifier
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • quintagroup.transmogrifier/trunk/quintagroup/transmogrifier/tests.py

    r1446 r1478  
    965965    test.globs['transmogrifier'].context = test.globs['plone'] 
    966966 
     967 
     968def interfaceManagerSetUp(test): 
     969    sectionsSetUp(test) 
     970 
     971    from zope.annotation.interfaces import IAttributeAnnotatable 
     972    from zope.interface import alsoProvides as orig_alsoProvides 
     973    from Products.Archetypes.interfaces import IBaseObject 
     974 
     975    class MockPortal(object): 
     976 
     977        implements( 
     978            IAttributeAnnotatable, 
     979            IBaseObject, 
     980        ) 
     981 
     982        _last_path = None 
     983        def unrestrictedTraverse(self, path, default): 
     984            if path[0] == '/': 
     985                return default # path is absolute 
     986            if isinstance(path, unicode): 
     987                return default 
     988            if path == 'not/existing/bar': 
     989                return default 
     990            if path.endswith('/notatcontent'): 
     991                return object() 
     992            self._last_path = path 
     993            return self 
     994 
     995 
     996    updated = [] 
     997    test.globs['updated'] = updated 
     998    def patch_alsoProvides(object, *interfaces): 
     999        updated.extend([i.__identifier__ for i in interfaces]) 
     1000        orig_alsoProvides(object, *interfaces) 
     1001    quintagroup.transmogrifier.interfacemanager.alsoProvides = patch_alsoProvides 
     1002 
     1003    portal = MockPortal() 
     1004    test.globs['plone'] = portal 
     1005    test.globs['transmogrifier'].context = test.globs['plone'] 
     1006 
     1007    class InterfaceManagerSource(SampleSource): 
     1008        classProvides(ISectionBlueprint) 
     1009        implements(ISection) 
     1010 
     1011        def __init__(self, *args, **kw): 
     1012            super(InterfaceManagerSource, self).__init__(*args, **kw) 
     1013            self.sample = ( 
     1014                dict(), 
     1015                dict(_path='not/existing/bar'), 
     1016                dict(_path='spam/eggs/notatcontent'), 
     1017                dict(_path='spam/eggs/foo'), 
     1018            ) 
     1019 
     1020    provideUtility(InterfaceManagerSource, 
     1021        name=u'quintagroup.transmogrifier.tests.interfacemanagersource') 
     1022 
     1023 
    9671024def test_suite(): 
    9681025    import sys 
     
    10081065            'flushcache.txt', 
    10091066            setUp=flushCacheSetUp, tearDown=tearDown), 
     1067        doctest.DocFileSuite( 
     1068            'interfacemanager.txt', 
     1069            setUp=interfaceManagerSetUp, tearDown=tearDown), 
    10101070    )) 
    10111071    return suite 
Note: See TracChangeset for help on using the changeset viewer.