Ejemplo n.º 1
0
 def testPloneSurveyQuestion(self):
     assert verifyClass(IPloneSurveyQuestion, SurveyMatrixQuestion)
     assert IPloneSurveyQuestion.implementedBy(SurveyMatrixQuestion)
     assert verifyClass(IPloneSurveyQuestion, SurveySelectQuestion)
     assert IPloneSurveyQuestion.implementedBy(SurveySelectQuestion)
     assert verifyClass(IPloneSurveyQuestion, SurveyTextQuestion)
     assert IPloneSurveyQuestion.implementedBy(SurveyTextQuestion)
Ejemplo n.º 2
0
    def test_interfaces(self):
        from Products.PluginIndexes.interfaces import ITopicIndex
        from Products.PluginIndexes.interfaces import IPluggableIndex
        from zope.interface.verify import verifyClass

        verifyClass(ITopicIndex, TopicIndex)
        verifyClass(IPluggableIndex, TopicIndex)
Ejemplo n.º 3
0
 def test_implements(self):
     from zope.interface.verify import verifyClass
     from repoze.who.interfaces import IIdentifier
     from repoze.who.interfaces import IChallenger
     klass = self._getTargetClass()
     verifyClass(IIdentifier, klass)
     verifyClass(IChallenger, klass)
Ejemplo n.º 4
0
    def test(self):

        field = Text(title=u"Foo thing")

        class I(Interface):

            getFoo, setFoo = accessors(field)

        class Bad(object):
            implements(I)

        class Good(object):
            implements(I)
            
            def __init__(self):
                self.set = 0

            def getFoo(self):
                return u"foo"

            def setFoo(self, v):
                self.set += 1

        names = I.names()
        names.sort()
        self.assertEqual(names, ['getFoo', 'setFoo'])
        self.assertEqual(I['getFoo'].field, field)
        self.assertEqual(I['getFoo'].__name__, 'getFoo')
        self.assertEqual(I['getFoo'].__doc__, u'get Foo thing')
        self.assertEqual(I['getFoo'].__class__, FieldReadAccessor)
        self.assertEqual(I['getFoo'].writer, I['setFoo'])

        # test some field attrs
        for attr in ('title', 'description', 'readonly'):
            self.assertEqual(getattr(I['getFoo'], attr), getattr(field, attr))

        self.assert_(IText.providedBy(I['getFoo']))
        
        self.assert_(IMethod.providedBy(I['getFoo']))
        self.assert_(IMethod.providedBy(I['setFoo']))

        self.assertEqual(I['setFoo'].field, field)
        self.assertEqual(I['setFoo'].__name__, 'setFoo')
        self.assertEqual(I['setFoo'].__doc__, u'set Foo thing')
        self.assertEqual(I['setFoo'].__class__, FieldWriteAccessor)

        self.assertRaises(Exception, verifyClass, I, Bad)
        self.assertRaises(Exception, verifyObject, I, Bad())
        
        self.assertEquals(I['getFoo'].query(Bad(), 42), 42)
        self.assertRaises(AttributeError, I['getFoo'].get, Bad())

        verifyClass(I, Good)
        verifyObject(I, Good())

        self.assertEquals(I['getFoo'].query(Good(), 42), u'foo')
        self.assertEquals(I['getFoo'].get(Good()), u'foo')
        instance = Good()
        I['getFoo'].set(instance, u'whatever')
        self.assertEquals(instance.set, 1)
Ejemplo n.º 5
0
    def test_z3interfaces(self):
        from zope.interface.verify import verifyClass
        from Products.CMFDefault.interfaces import ILink
        from Products.CMFDefault.interfaces import IMutableLink

        verifyClass(ILink, self._getTargetClass())
        verifyClass(IMutableLink, self._getTargetClass())
Ejemplo n.º 6
0
    def test_z2interfaces(self):
        from Interface.Verify import verifyClass
        from Products.CMFCore.ActionInformation import ActionInfo
        from Products.CMFCore.interfaces.portal_actions \
                import ActionInfo as IActionInfo

        verifyClass(IActionInfo, ActionInfo)
Ejemplo n.º 7
0
 def test_UserManagerInterfaces(self):
   """Tests user manager plugin respects interfaces."""
   from Products.PluggableAuthService.interfaces.plugins import\
               IAuthenticationPlugin, IUserEnumerationPlugin
   from Products.ERP5Security.ERP5UserManager import ERP5UserManager
   verifyClass(IAuthenticationPlugin, ERP5UserManager)
   verifyClass(IUserEnumerationPlugin, ERP5UserManager)
Ejemplo n.º 8
0
    def test_ILoginPasswordHostExtractionPlugin_conformance( self ):

        from Products.PluggableAuthService.interfaces.plugins \
            import ILoginPasswordHostExtractionPlugin

        verifyClass( ILoginPasswordHostExtractionPlugin
                   , self._getTargetClass() )
Ejemplo n.º 9
0
    def test_interfaces(self):
        from Products.CMFCore.interfaces import IContentish
        from Products.CMFCore.interfaces import IDynamicType
        from Products.CMFCore.PortalContent import PortalContent

        verifyClass(IContentish, PortalContent)
        verifyClass(IDynamicType, PortalContent)
Ejemplo n.º 10
0
    def test_z2interfaces(self):
        from Interface.Verify import verifyClass
        from Products.CMFCore.CachingPolicyManager import CachingPolicyManager
        from Products.CMFCore.interfaces.CachingPolicyManager \
                import CachingPolicyManager as ICachingPolicyManager

        verifyClass(ICachingPolicyManager, CachingPolicyManager)
    def test_z3interfaces(self):
        from Products.PluginIndexes.interfaces import IPluggableIndex
        from Products.ZCTextIndex.interfaces import IZCTextIndex
        from zope.interface.verify import verifyClass

        verifyClass(IPluggableIndex, ZCTextIndex)
        verifyClass(IZCTextIndex, ZCTextIndex)
Ejemplo n.º 12
0
 def _load_entry(self, entry):
     # pylint: disable=W0703
     if self._check_extras:
         try:
             entry.require()
         except Exception as err:
             raise PluginDBError('Requirements are not satisfied '
                                 'for %s:%s: %s' % (self._group,
                                                    entry.name,
                                                    str(err)))
     try:
         result = entry.load()
     except Exception as err:
         # log full traceback of the bad entry to help support
         traceback.print_exc()
         raise PluginDBError('Unable to load %s:%s: %s' %
                             (self._group, entry.name, str(err)))
     if self._interface:
         try:
             verifyClass(self._interface, result)
         except Invalid as err:
             raise PluginDBError('Plugin %s:%s does not implement %s: %s' %
                                 (self._group, entry.name,
                                  self._interface.__name__, str(err)))
     return result
 def test_interface_conformance(self):
     from zope.interface.verify import verifyClass, verifyObject
     from ..interfaces import IShadowTreeTool
     verifyClass(IShadowTreeTool, self._get_target_class())
     util = self._make_one()
     verifyObject(IShadowTreeTool, util)
     IShadowTreeTool.validateInvariants(util)
Ejemplo n.º 14
0
 def test_alias_class_implements(self):
     from zope.interface.verify import verifyClass
     from pyramid.events import AfterTraversal
     from pyramid.interfaces import IAfterTraversal
     from pyramid.interfaces import IContextFound
     verifyClass(IAfterTraversal, AfterTraversal)
     verifyClass(IContextFound, AfterTraversal)
Ejemplo n.º 15
0
    def test_interfaces(self):
        from Products.CMFCore.MemberDataTool import MemberDataFactory
        from Products.CMFCore.interfaces import IMemberData
        from zope.component import IFactory

        verifyClass(IFactory, MemberDataFactory)
        verifyClass(IMemberData, MemberDataFactory)
Ejemplo n.º 16
0
    def test_interfaces(self):
        from Products.CMFCore.interfaces import IActionProvider
        from Products.CMFCore.interfaces import IURLTool
        from Products.CMFCore.URLTool import URLTool

        verifyClass(IActionProvider, URLTool)
        verifyClass(IURLTool, URLTool)
Ejemplo n.º 17
0
 def test_alias_class_implements(self):
     from pyramid.events import WSGIApplicationCreatedEvent
     from pyramid.interfaces import IWSGIApplicationCreatedEvent
     from pyramid.interfaces import IApplicationCreated
     from zope.interface.verify import verifyClass
     verifyClass(IWSGIApplicationCreatedEvent, WSGIApplicationCreatedEvent)
     verifyClass(IApplicationCreated, WSGIApplicationCreatedEvent)
Ejemplo n.º 18
0
    def test_interfaces(self):
        from OFS.interfaces import IWriteLock
        from webdav.interfaces import IDAVResource
        from zope.interface.verify import verifyClass

        verifyClass(IDAVResource, self._getTargetClass())
        verifyClass(IWriteLock, self._getTargetClass())
Ejemplo n.º 19
0
 def test_sauropod_backend(self):
     try:
         from appsync.storage.sauropod import SauropodDatabase
     except ImportError:
         pass
     else:
         verifyClass(IAppSyncDatabase, SauropodDatabase)
Ejemplo n.º 20
0
    def test_interfaces(self):
        from Products.CMFCore.interfaces import IActionProvider
        from Products.CMFCore.interfaces import ITypesTool
        from Products.CMFCore.TypesTool import TypesTool

        verifyClass(IActionProvider, TypesTool)
        verifyClass(ITypesTool, TypesTool)
Ejemplo n.º 21
0
    def test_z3interfaces(self):
        from zope.interface.verify import verifyClass
        from Products.CMFCalendar.interfaces import IEvent
        from Products.CMFCalendar.interfaces import IMutableEvent

        verifyClass(IEvent, self._getTargetClass())
        verifyClass(IMutableEvent, self._getTargetClass())
Ejemplo n.º 22
0
    def test_xml_generator_implements(self):
        self.replay()

        self.assertTrue(i.IMopageEventXMLGenerator.implementedBy(
           xml_generator.MopageEventXMLGenerator))

        verifyClass(i.IMopageEventXMLGenerator, xml_generator.MopageEventXMLGenerator)
Ejemplo n.º 23
0
    def test_interfaces(self):
        from Products.CMFCore.DiscussionTool import DiscussionTool
        from Products.CMFCore.interfaces import IActionProvider
        from Products.CMFCore.interfaces import IOldstyleDiscussionTool

        verifyClass(IActionProvider, DiscussionTool)
        verifyClass(IOldstyleDiscussionTool, DiscussionTool)
Ejemplo n.º 24
0
def add_metadata_field(config, metadata_cls):
    verifyClass(IMetadata, metadata_cls)
    for ar in config.registry.registeredAdapters():
        if ar.provided == IMetadata and ar.name == metadata_cls.name: #pragma : no coverage
            logger.warn("Metadata adapter %r already registered with name %r. "
                        "Registering %r might override it." % (ar.factory, ar.name, metadata_cls))
    config.registry.registerAdapter(metadata_cls, name = metadata_cls.name)
Ejemplo n.º 25
0
    def test_z3interfaces(self):
        from Products.PluginIndexes.interfaces import IPathIndex
        from Products.PluginIndexes.interfaces import IUniqueValueIndex
        from zope.interface.verify import verifyClass

        verifyClass(IPathIndex, PathIndex)
        verifyClass(IUniqueValueIndex, PathIndex)
Ejemplo n.º 26
0
    def test_conformance(self):
        from zope.interface.verify import verifyClass
        from zope.interface.verify import verifyObject
        from pyramid.interfaces import IIntrospectable

        verifyClass(IIntrospectable, self._getTargetClass())
        verifyObject(IIntrospectable, self._makeOnePopulated())
 def test_class_conforms_to_IWriteLock(self):
     from zope.interface.verify import verifyClass
     try:
         from OFS.interfaces import IWriteLock
     except ImportError:
         from webdav.interfaces import IWriteLock
     verifyClass(IWriteLock, PythonScript)
Ejemplo n.º 28
0
    def test_data_provider_implements(self):
        self.replay()

        self.assertTrue(i.IMopageEventDataProvider.implementedBy(
            data_provider.MopageEventDataProvider))

        verifyClass(i.IMopageEventObjectLookup, object_lookup.MopageEventObjectLookup)
    def test_interfaces(self):
        from ..interfaces import IContentish
        from ..interfaces import IDynamicType
        from ..PortalContent import PortalContent

        verifyClass(IContentish, PortalContent)
        verifyClass(IDynamicType, PortalContent)
Ejemplo n.º 30
0
    def test_implements_interface(self):
        self.replay()
        utility = getUtility(IBridgeRequest)
        klass = type(utility)

        self.assertTrue(IBridgeRequest.implementedBy(klass))
        verifyClass(IBridgeRequest, klass)
Ejemplo n.º 31
0
 def test_class_conforms_to_ICredentialsUpdatedEvent(self):
     from zope.interface.verify import verifyClass
     from Products.PluggableAuthService.interfaces.events \
         import ICredentialsUpdatedEvent
     verifyClass(ICredentialsUpdatedEvent, self._getTargetClass())
Ejemplo n.º 32
0
 def test_class_conforms_to_IQuip(self):
     from zope.interface.verify import verifyClass
     from karl.models.interfaces import IQuip
     verifyClass(IQuip, self._getTargetClass())
Ejemplo n.º 33
0
 def test_verify(self):
     assert verifyClass(
         IAuthenticationPolicy,
         auth_policy.SessionAuthenticationPolicy,
     )
Ejemplo n.º 34
0
 def test_verify(self):
     assert verifyClass(
         IAuthenticationPolicy,
         auth_policy.BasicAuthAuthenticationPolicy,
     )
 def test_interface(self):
     from zope.interface.verify import verifyClass
     verifyClass(IMembershipTool, MembershipTool)
Ejemplo n.º 36
0
 def test_verify_class(self):
     self.assertTrue(verifyClass(IPoll, self._cut))
Ejemplo n.º 37
0
 def testInterfacesVerify(self):
     for interface in implementedBy(ZopePublication):
         verifyClass(interface, TestPublication)
Ejemplo n.º 38
0
 def test_implements(self):
     from who_ldap import LDAPAttributesPlugin
     from zope.interface.verify import verifyClass
     from repoze.who.interfaces import IMetadataProvider
     verifyClass(IMetadataProvider, LDAPAttributesPlugin, tentative=True)
Ejemplo n.º 39
0
 def test_implements_interface(self):
     verifyClass(IUpgradeStep, UpgradeStep)
Ejemplo n.º 40
0
 def test_class_conforms_to_IPrincipalDeletedEvent(self):
     from zope.interface.verify import verifyClass
     from Products.PluggableAuthService.interfaces.events \
         import IPrincipalDeletedEvent
     verifyClass(IPrincipalDeletedEvent, self._getTargetClass())
Ejemplo n.º 41
0
 def test_class_conforms_to_IPackageOverrides(self):
     from zope.interface.verify import verifyClass
     from pyramid.interfaces import IPackageOverrides
     verifyClass(IPackageOverrides, self._getTargetClass())
Ejemplo n.º 42
0
 def test_implements(self):
     from zope.interface.verify import verifyClass
     from repoze.who.interfaces import IAuthenticator
     from who_ldap import LDAPAuthenticatorPlugin
     verifyClass(IAuthenticator, LDAPAuthenticatorPlugin, tentative=True)
Ejemplo n.º 43
0
 def test_interfaces(self):
     verifyClass(IComponent, Service)
Ejemplo n.º 44
0
 def test_class_conforms_to_IPEP302Loader(self):
     from zope.interface.verify import verifyClass
     from pyramid.interfaces import IPEP302Loader
     verifyClass(IPEP302Loader, self._getTargetClass())
Ejemplo n.º 45
0
 def test_verify_service(self):
     assert verifyClass(IUserService, services.DatabaseUserService)
Ejemplo n.º 46
0
 def test_class_conforms_to_IPermission(self):
     from zope.interface.verify import verifyClass
     from zope.security.interfaces import IPermission
     verifyClass(IPermission, self._getTargetClass())
Ejemplo n.º 47
0
 def test_verify_service(self):
     assert verifyClass(IPasswordBreachedService,
                        services.HaveIBeenPwnedPasswordBreachedService)
Ejemplo n.º 48
0
 def test_verify_service(self):
     assert verifyClass(ITokenService, services.TokenService)
Ejemplo n.º 49
0
    def test_conforms_to_IMemCacheSessionDataContainer(self):
        from zope.interface.verify import verifyClass

        from ..interfaces import IMemCacheSessionDataContainer
        verifyClass(IMemCacheSessionDataContainer, self._getTargetClass())
Ejemplo n.º 50
0
 def test_verify_service(self):
     assert verifyClass(IPasswordBreachedService,
                        services.NullPasswordBreachedService)
 def test_verify_implemented_interfaces(self):
     verifyClass(IBumblebeeOverlay, BumblebeeMailOverlay)
Ejemplo n.º 52
0
 def test_class_conforms_to_IZCLexicon(self):
     from Products.ZCTextIndex.interfaces import IZCLexicon
     from zope.interface.verify import verifyClass
     verifyClass(IZCLexicon, self._getTargetClass())
Ejemplo n.º 53
0
    def test_interfaces(self):
        from Products.CMFCore.interfaces import ICookieCrumbler

        verifyClass(ICookieCrumbler, self._getTargetClass())
Ejemplo n.º 54
0
 def testInterfaceComplete(self):
     self.assertTrue(
         verifyClass(IContentListingObject, FlareContentListingObject))
Ejemplo n.º 55
0
 def test_class_conforms_to_IWriteLock(self):
     from zope.interface.verify import verifyClass
     from webdav.interfaces import IWriteLock
     verifyClass(IWriteLock, self._getTargetClass())
Ejemplo n.º 56
0
    def _guessComparisonOperator(self, value):
        if isinstance(value, basestring) and '%' in value:
            operator = 'like'
        else:
            operator = SearchKey._guessComparisonOperator(self, value)
        return operator

    def _renderValueAsSearchText(self, value, operator):
        return operator.asSearchText(value)

    def buildSearchTextExpression(self, operator, value, column=None):
        operator_text = operator.getOperator()
        if column is None:
            column = self.getColumn()
        if operator_text == 'like':
            assert isinstance(value, basestring)
            assert '%' in value
            result = self._renderValueAsSearchText(value, operator)
            if len(column):
                result = '%s:%s' % (column, result)
        else:
            result = SearchKey.buildSearchTextExpression(self,
                                                         operator,
                                                         value,
                                                         column=column)
        return result


verifyClass(ISearchKey, DefaultKey)
Ejemplo n.º 57
0
    def test_interfaces(self):
        from Products.CMFCore.interfaces import ICallableOpaqueItemEvents
        from Products.CMFCore.interfaces import IDiscussable

        verifyClass(ICallableOpaqueItemEvents, self._getTargetClass())
        verifyClass(IDiscussable, self._getTargetClass())
Ejemplo n.º 58
0
        return self.wrapped_query._asSearchTextExpression(sql_catalog,
                                                          column=column)

    def asSearchTextExpression(self, sql_catalog, column=None):
        if self.wrapped_query is None:
            self._createWrappedQuery(sql_catalog)
        return self.wrapped_query.asSearchTextExpression(sql_catalog,
                                                         column=column)

    def asSQLExpression(self, sql_catalog, column_map, only_group_columns):
        if self.wrapped_query is None:
            self._createWrappedQuery(sql_catalog)
        return self.wrapped_query.asSQLExpression(
            sql_catalog, column_map, only_group_columns=only_group_columns)

    def registerColumnMap(self, sql_catalog, column_map):
        if self.wrapped_query is None:
            self._createWrappedQuery(sql_catalog)
        return self.wrapped_query.registerColumnMap(sql_catalog, column_map)

    def __repr__(self):
        if self.wrapped_query is None:
            result = '<%s(operator=%r, **%r) at %s>' % (
                self.__class__.__name__, self.operator, self.kw, id(self))
        else:
            result = '<%s %r>' % (self.__class__.__name__, self.wrapped_query)
        return result


verifyClass(IQuery, AutoQuery)
Ejemplo n.º 59
0
    def test_interfaces(self):
        from Products.CMFCore.interfaces import ICatalogableDublinCore
        from Products.CMFCore.interfaces import IContentish
        from Products.CMFCore.interfaces import IDiscussionResponse
        from Products.CMFCore.interfaces import IDublinCore
        from Products.CMFCore.interfaces import IDynamicType
        from Products.CMFCore.interfaces import IMutableDublinCore
        from Products.CMFDefault.DiscussionItem import DiscussionItem

        verifyClass(ICatalogableDublinCore, DiscussionItem)
        verifyClass(IContentish, DiscussionItem)
        verifyClass(IDiscussionResponse, DiscussionItem)
        verifyClass(IDublinCore, DiscussionItem)
        verifyClass(IDynamicType, DiscussionItem)
        verifyClass(IMutableDublinCore, DiscussionItem)
Ejemplo n.º 60
0
    def test_interfaces(self):
        from Products.CMFCore.DiscussionTool import OldDiscussable
        from Products.CMFCore.interfaces import IOldstyleDiscussable

        verifyClass(IOldstyleDiscussable, OldDiscussable)