Exemplo n.º 1
0
    def setUp(self):
        placelesssetup.setUp(self)

        self.mailhost = stubydoo.double()

        class IPossibleSubscriberProvider(zope.interface.Interface):
            pass
        self.subscriber = stubydoo.double()
        self.subscribers = [self.subscriber]
        self.newsletter = stubydoo.double()
        self.message = stubydoo.double()

        stubydoo.stub(self.newsletter, 'compile').with_args(self.subscriber).\
            and_return(self.message)
        stubydoo.stub(self.mailhost, 'send').with_args(self.message)

        @zope.component.adapter(None)
        @zope.interface.implementer(interfaces.INewsletter)
        def newsletter_adapter(context):
            self.newsletter.context = context
            return self.newsletter
        zope.component.provideAdapter(newsletter_adapter)

        self.context = stubydoo.double()
        self.mailing = mailing.Mailing()
Exemplo n.º 2
0
def setUpObjectEventDocTest(test) :
    setUp()
        
    ztapi.provideAdapter(IAttributeAnnotatable,
                                IAnnotations, AttributeAnnotations) 
    ztapi.provideAdapter(IAnnotatable,
                                IZopeDublinCore, ZDCAnnotatableAdapter)    
Exemplo n.º 3
0
    def afterSetUp(self):
        setUp()
        zcml.load_config("meta.zcml", Products.Five)
        zcml.load_config("permissions.zcml", Products.Five)
        zcml.load_config("configure.zcml", Products.Five.component)
        zcml.load_config("configure.zcml", Products.Five.site)
        zcml_text = """\
        <five:localsite
            xmlns:five="http://namespaces.zope.org/five"
            class="Products.Five.site.tests.dummy.DummySite" />"""

        import warnings
        showwarning = warnings.showwarning
        warnings.showwarning = lambda *a, **k: None

        zcml.load_string(zcml_text)
        manage_addDummySite(self.folder, 'site')
        enableLocalSiteHook(self.folder.site)

        warnings.showwarning = showwarning

        # Hook up custom component architecture calls; we need to do
        # this here because zope.app.component.hooks registers a
        # cleanup with the testing cleanup framework, so the hooks get
        # torn down by placelesssetup each time.
        setHooks()
    def setUp(self):
        placelesssetup.setUp(self)
        self.config = stubydoo.double()

        # This kind of document uses a rich text field, which has an output
        # attribute.
        self.document = stubydoo.double(body=stubydoo.double())
        self.document.body = u'<p>Test!</p>'

        @zope.component.adapter(None)
        @zope.interface.implementer(interfaces.IHTMLBody)
        def html_body(doc):
            return doc.body
        zope.component.provideAdapter(html_body)

        self.compiler = StyledPageCompilationStrategy(self.document, self.config)

        # This 'stubbing' relies on the fact that the function is accessed
        # through module's getattr always, no references kept.
        from tn.plonestyledpage import styled_page
        self.old_getUniqueId = styled_page.getUniqueId
        styled_page.getUniqueId = lambda page: u'foo'

        self.old_getEscapedStyleBlock = styled_page.getEscapedStyleBlock
        styled_page.getEscapedStyleBlock = lambda page: u'<style>%s</style>' % page.styles

        self.document.styles = u'p{color:red}'
Exemplo n.º 5
0
def setUpCategory(test):
    placelesssetup.setUp(test)
    ztapi.provideAdapter(IAttributeAnnotatable, IAnnotations,
                         AttributeAnnotations)
    container = SampleContainer()
    test.globs = {'my_container': container}
    directlyProvides(container, IAttributeAnnotatable)
Exemplo n.º 6
0
def setUpRelatedAttribution(test):
    placelesssetup.setUp(test)
    setUpZCML(test)
    test.globs['root'] = root = rootFolder()
    testing.setUpIndices(test)
    testing.setUpIntIds(test)
    interaction = newInteraction()
Exemplo n.º 7
0
def sessionSetUp(session_data_container_class=PersistentSessionDataContainer):
    placelesssetup.setUp()
    ztapi.provideAdapter(IRequest, IClientId, TestClientId)
    ztapi.provideAdapter(IRequest, ISession, Session)
    ztapi.provideUtility(IClientIdManager, CookieClientIdManager())
    sdc = session_data_container_class()
    ztapi.provideUtility(ISessionDataContainer, sdc, '')
Exemplo n.º 8
0
    def afterSetUp(self):
        setUp()
        zcml.load_config("meta.zcml", Products.Five)
        zcml.load_config("permissions.zcml", Products.Five)
        zcml.load_config("configure.zcml", Products.Five.component)
        zcml.load_config("configure.zcml", Products.Five.site)
        zcml_text = """\
        <five:localsite
            xmlns:five="http://namespaces.zope.org/five"
            class="Products.Five.site.tests.dummy.DummySite" />"""

        import warnings
        showwarning = warnings.showwarning
        warnings.showwarning = lambda *a, **k: None

        zcml.load_string(zcml_text)
        manage_addDummySite(self.folder, 'site')
        enableLocalSiteHook(self.folder.site)
        
        warnings.showwarning = showwarning

        # Hook up custom component architecture calls; we need to do
        # this here because zope.app.component.hooks registers a
        # cleanup with the testing cleanup framework, so the hooks get
        # torn down by placelesssetup each time.
        setHooks()
Exemplo n.º 9
0
 def setUp(self):
     placelesssetup.setUp()
     factory = self.getTestClass()
     iface = self.getTestInterface()
     required = self.getAdaptedClass()
     # register language switch for test interface adapter
     ztapi.provideAdapter(required, iface, factory)
Exemplo n.º 10
0
def setUp(test):
    placelesssetup.setUp(test)
    setUpContents()
    component.provideAdapter(
        AnnotationPrincipalPermissionManager, (interface.Interface,))

    setup.setUpTestAsModule(test, 'zojax.content.permissions.TESTS')
Exemplo n.º 11
0
def setUp(test):
    placelesssetup.setUp(test)
    testing.setUp()
    component.provideAdapter(view, (None, None), ITraversable, name="view")

    component.provideUtility(
        fileresource.filefactory, IResourceFactoryType)
    component.provideUtility(
        fileresource.filefactory, IResourceFactoryType, name='fileresource')
    component.provideUtility(
        fileresource.imagefactory, IResourceFactoryType, name='imageresource')
    component.provideUtility(
        zrtresource.zrtfactory, IResourceFactoryType, name='zrt')

    component.provideAdapter(
        fileresource.FileResourceAdapter, (FileResource,))

    component.provideUtility(
        command.cssregistry_factory, IZRTCommandFactory, 'cssregistry')

    registry = CSSRegistry()
    registry['fontColor']= property.Property('fontColor', '#11111111')
    registry['fontFamily']= property.Property('fontFamily', 'Verdana')

    component.provideAdapter(
        zcml.Factory(registry),
        (interfaces.ICSSRegistryLayer, interfaces.ICSSRegistryLayer,
         interface.Interface), interfaces.ICSSRegistry, '')
    def setUp(self):
        placelesssetup.setUp(self)

        self.configuration = GlobalConfiguration(
            subscriber_name_xpath=u'',
            add_subscriber_preferences=False,
            subscriber_preferences_url_xpath=u'',
            subscriber_preferences_html=u'',
            add_subscriber_removal=True,
            subscriber_removal_url_xpath=u'',
            subscriber_removal_html=u'',
            inline_styles=False,
        )
        zope.component.provideUtility(self.configuration)

        self.newsletter_attributes = stubydoo.double()
        self.context = stubydoo.double()
        request = object()
        self.newsletter = newsletter.Newsletter(self.context, request,
                                                self.newsletter_attributes)

        self.message_factory = stubydoo.double(__call__=lambda x, c: c)

        @zope.component.adapter(None, None, None, None)
        @zope.interface.implementer(interfaces.IMessageFactory)
        def message_factory_factory(context, request, newsletter, subscriber):
            return self.message_factory

        zope.component.provideAdapter(message_factory_factory)
Exemplo n.º 13
0
    def setUp(self):
        placelesssetup.setUp(self)
        self.context = zope.container.folder.Folder()
        self.request = stubydoo.double(form={})
        self.add_form = AddForm(self.context)

        self.adder = subscriber_list.SubscriberAdder(self.context,
                                                     self.request,
                                                     self.add_form)

        dates_locale = stubydoo.double()
        self.request.locale = stubydoo.double(dates=dates_locale)

        self.parsed_datetime = datetime.datetime.now()
        self.date_short_fmt = stubydoo.double(
            parse=lambda f, x: self.parsed_datetime
        )

        stubydoo.stub(dates_locale, 'getFormatter').\
                with_args('date', 'short').and_return(self.date_short_fmt)
        stubydoo.stub(dates_locale, 'getFormatter').\
                with_args('date', 'medium').\
                and_return(stubydoo.double(parse='ignored'))
        stubydoo.stub(dates_locale, 'getFormatter').\
                with_args('dateTime', 'short').\
                and_return(stubydoo.double(parse='ignored'))
        stubydoo.stub(dates_locale, 'getFormatter').\
                with_args('dateTime', 'medium').\
                and_return(stubydoo.double(parse='ignored'))

        zope.component.provideAdapter(Publication)
    def setUp(self):
        placelesssetup.setUp(self)

        self.configuration = GlobalConfiguration(
            subscriber_name_xpath=u'',
            add_subscriber_preferences=False,
            subscriber_preferences_url_xpath=u'',
            subscriber_preferences_html=u'',
            add_subscriber_removal=True,
            subscriber_removal_url_xpath=u'',
            subscriber_removal_html=u'',
            inline_styles=False,
        )
        zope.component.provideUtility(self.configuration)

        self.newsletter_attributes = stubydoo.double()
        self.context = stubydoo.double()
        request = object()
        self.newsletter = newsletter.Newsletter(self.context,
                                                request,
                                                self.newsletter_attributes)

        self.message_factory = stubydoo.double(__call__=lambda x, c: c)

        @zope.component.adapter(None, None, None, None)
        @zope.interface.implementer(interfaces.IMessageFactory)
        def message_factory_factory(context, request, newsletter, subscriber):
            return self.message_factory

        zope.component.provideAdapter(message_factory_factory)
Exemplo n.º 15
0
def sessionSetUp(session_data_container_class=PersistentSessionDataContainer):
    placelesssetup.setUp()
    provideAdapter(TestClientId, [IRequest], IClientId)
    provideAdapter(Session, [IRequest], ISession)
    provideUtility(CookieClientIdManager(), IClientIdManager)
    sdc = session_data_container_class()
    provideUtility(sdc, ISessionDataContainer, '')
Exemplo n.º 16
0
def setUpCategory(test):
    placelesssetup.setUp(test)
    ztapi.provideAdapter(IAttributeAnnotatable, IAnnotations,
                         AttributeAnnotations)
    container = SampleContainer()
    test.globs = {'my_container': container}
    directlyProvides(container, IAttributeAnnotatable)
Exemplo n.º 17
0
 def setUp(self):
     setUp()
     from bibliograph.rendering.interfaces import IBibTransformUtility
     from bibliograph.rendering.utility import ExternalTransformUtility
     ztapi.provideUtility(IBibTransformUtility,
                          ExternalTransformUtility(),
                          name=u'external')
Exemplo n.º 18
0
def sessionSetUp(session_data_container_class=PersistentSessionDataContainer):
    placelesssetup.setUp()
    ztapi.provideAdapter(IRequest, IClientId, TestClientId)
    ztapi.provideAdapter(IRequest, ISession, Session)
    ztapi.provideUtility(IClientIdManager, CookieClientIdManager())
    sdc = session_data_container_class()
    ztapi.provideUtility(ISessionDataContainer, sdc, '')
Exemplo n.º 19
0
def nonHTTPSessionTestCaseSetUp(sdc_class=PersistentSessionDataContainer):
    # I am getting an error with ClientId and not TestClientId
    placelesssetup.setUp()
    provideAdapter(ClientId, [IRequest], IClientId)
    provideAdapter(Session, [IRequest], ISession)
    provideUtility(CookieClientIdManager(), IClientIdManager)
    sdc = sdc_class()
    provideUtility(sdc, ISessionDataContainer, '')
Exemplo n.º 20
0
def nonHTTPSessionTestCaseSetUp(sdc_class=PersistentSessionDataContainer):
    # I am getting an error with ClientId and not TestClientId
    placelesssetup.setUp()
    ztapi.provideAdapter(IRequest, IClientId, ClientId)
    ztapi.provideAdapter(IRequest, ISession, Session)
    ztapi.provideUtility(IClientIdManager, CookieClientIdManager())
    sdc = sdc_class()
    ztapi.provideUtility(ISessionDataContainer, sdc, '')
Exemplo n.º 21
0
def setUp(test):
    print "\n---------- SETUP ----------", test
    placelesssetup.setUp()
    xmlconfig.string(zcml_slug)
    metadata.create_all(checkfirst=True)
    # placelesssetup.tearDown() clears the registry
    print "\n---------- register_generic_workflow_adapters -------------", test
    adapters.register_generic_workflow_adapters()
Exemplo n.º 22
0
def nonHTTPSessionTestCaseSetUp(sdc_class=PersistentSessionDataContainer):
    # I am getting an error with ClientId and not TestClientId
    placelesssetup.setUp()
    ztapi.provideAdapter(IRequest, IClientId, ClientId)
    ztapi.provideAdapter(IRequest, ISession, Session)
    ztapi.provideUtility(IClientIdManager, CookieClientIdManager())
    sdc = sdc_class()
    ztapi.provideUtility(ISessionDataContainer, sdc, '')
Exemplo n.º 23
0
 def setUp(self):
     placelesssetup.setUp()
     ztapi.provideAdapter(IUtilityRegistration, IRegistrySearch,
                          UtilitySearch)
     ztapi.provideAdapter(IHandlerRegistration, IRegistrySearch,
                          HandlerSearch)
     ztapi.provideAdapter(IAdapterRegistration, IRegistrySearch,
                          AdapterSearch)
Exemplo n.º 24
0
def setUpDebug(test):
    placelesssetup.setUp(test)
    test.real_stderr = sys.stderr
    test.real_argv = list(sys.argv)
    test.olddir = os.getcwd()
    os.chdir(os.path.join(os.path.dirname(__file__), 'testdata'))
    from zope.security.management import endInteraction
    endInteraction()
Exemplo n.º 25
0
def setUp(test):
    print "\n---------- SETUP ----------", test
    placelesssetup.setUp()
    xmlconfig.string(zcml_slug)
    metadata.create_all(checkfirst=True)
    # placelesssetup.tearDown() clears the registry
    print "\n---------- register_generic_workflow_adapters -------------", test
    adapters.register_generic_workflow_adapters()
Exemplo n.º 26
0
def setUp(app):
    """A setup that includes the basic CA setup"""
    placelesssetup.setUp()
    import Products.Five
    zcml.load_config('meta.zcml', Products.Five)
    zcml.load_config('permissions.zcml', Products.Five)
    zcml.load_config('configure.zcml', Products.Five)
    base_setup(app)
Exemplo n.º 27
0
def processorSetUp(test):
    placelesssetup.setUp()
    ztapi.provideAdapter(IStore, IPaymentProcessor, OgoneStandardProcessor,
                         name='Ogone Payments')
    ztapi.provideAdapter(IStore, IOgoneStandardOptions, OgoneStandardOptions)
    ztapi.provideAdapter(annotation_interfaces.IAttributeAnnotatable,
                         annotation_interfaces.IAnnotations,
                         attribute.AttributeAnnotations)
Exemplo n.º 28
0
def lockingSetUp(test):
    placelesssetup.setUp(test)
    z3c.etree.testing.etreeSetup(test)

    # create principal
    participation = TestRequest(environ = {"REQUEST_METHOD": "PUT"})
    participation.setPrincipal(Principal("michael"))
    if queryInteraction() is not None:
        queryInteraction().add(participation)
    else:
        newInteraction(participation)

    events = test.globs["events"] = []
    zope.event.subscribers.append(events.append)

    gsm = zope.component.getGlobalSiteManager()

    gsm.registerAdapter(DemoKeyReference,
                        (IDemo,),
                        zope.app.keyreference.interfaces.IKeyReference)
    gsm.registerAdapter(PhysicallyLocatable, (Demo,))
    gsm.registerAdapter(PhysicallyLocatable, (DemoFolder,))
    gsm.registerAdapter(DemoKeyReference, (IDemoFolder,),
                        zope.app.keyreference.interfaces.IKeyReference)
    gsm.registerAdapter(SiteManagerAdapter,
                        (zope.interface.Interface,), IComponentLookup)
    gsm.registerAdapter(DemoAbsoluteURL,
                        (IDemo, zope.interface.Interface),
                        zope.traversing.browser.interfaces.IAbsoluteURL)
    gsm.registerAdapter(DemoAbsoluteURL,
                        (IDemoFolder, zope.interface.Interface),
                        zope.traversing.browser.interfaces.IAbsoluteURL)

    # register some IDAVWidgets so that we can render the activelock and
    # supportedlock widgets.
    gsm.registerAdapter(z3c.dav.widgets.ListDAVWidget,
                        (zope.schema.interfaces.IList,
                         z3c.dav.interfaces.IWebDAVRequest))
    gsm.registerAdapter(z3c.dav.widgets.ObjectDAVWidget,
                        (zope.schema.interfaces.IObject,
                         z3c.dav.interfaces.IWebDAVRequest))
    gsm.registerAdapter(z3c.dav.widgets.TextDAVWidget,
                        (zope.schema.interfaces.IText,
                         z3c.dav.interfaces.IWebDAVRequest))
    gsm.registerAdapter(z3c.dav.properties.OpaqueWidget,
                        (z3c.dav.properties.DeadField,
                         z3c.dav.interfaces.IWebDAVRequest))
    gsm.registerAdapter(z3c.dav.widgets.TextDAVWidget,
                        (zope.schema.interfaces.IURI,
                         z3c.dav.interfaces.IWebDAVRequest))

    # Need connection to a database to manage locking
    db = test.globs["db"] = ZODB.DB(ZODB.MappingStorage.MappingStorage())
    test.globs["conn"] = db.open()

    # expose these classes to the test
    test.globs["Demo"] = Demo
    test.globs["DemoFolder"] = DemoFolder
Exemplo n.º 29
0
    def setUp(self):
        placelesssetup.setUp(self)
        self.portal = self.make_portal()
        setSite(self.portal)
        self.provide_mailhost(self.make_mailhost('MailHost'))

        self.portal['folder'] = stubydoo.double()

        self.mailing = mailing.Mailing()
Exemplo n.º 30
0
def baseIntegration(test):
    placelesssetup.setUp(test)
    directlyProvides(IEditorialRating, IRatingType)
    directlyProvides(IUserRating, IRatingType)
    ztapi.provideAdapter(IAttributeAnnotatable, IAnnotations,
                         AttributeAnnotations)
    ztapi.provideAdapter((IRatingCategory, Interface),
                         IRatingManager, RatingCategoryAdapter)
    container = SampleContainer()
    test.globs = {'my_container': container}
Exemplo n.º 31
0
def setUp(session_data_container_class=PersistentSessionDataContainer):
    placelesssetup.setUp()
    ztapi.provideAdapter(IRequest, IClientId, ClientId)
    ztapi.provideAdapter(IRequest, ISession, Session)
    ztapi.provideUtility(IClientIdManager, CookieClientIdManager())
    sdc = session_data_container_class()
    for product_id in ('', 'products.foo', 'products.bar', 'products.baz'):
        ztapi.provideUtility(ISessionDataContainer, sdc, product_id)
    request = HTTPRequest(StringIO(), {}, None)
    return request
 def setUp(self):
     placelesssetup.setUp(self)
     self.cache = {}
     self.context_keys = double(link=lambda *a:None,
                                unlink=lambda *a:None,
                                unlinkContext=lambda *a:None,
                                __contains__=lambda *a:True)
     zope.component.provideUtility(self.cache, interfaces.ICache)
     zope.component.provideUtility(self.context_keys,
                                   interfaces.IContextKeys)
     self.cache_manager = caching.CacheManager()
Exemplo n.º 33
0
def setUp(test):
    placelesssetup.setUp()
    testing.setUp()

    endInteraction()

    principal = principalregistry.UnauthenticatedPrincipal('anon','anon','')
    component.provideUtility(
        principal, IFallbackUnauthenticatedPrincipal)
    component.provideUtility(
        principalregistry.principalRegistry, IAuthentication)
    def setUp(self):
        placelesssetup.setUp(self)

        self.context = stubydoo.double()
        self.adapted = stubydoo.double()

        @zope.component.adapter(None)
        @zope.interface.implementer(interfaces.INewsletterAttributes)
        def newsletter_attributes_adapter(obj):
            return self.adapted
        zope.component.provideAdapter(newsletter_attributes_adapter)
Exemplo n.º 35
0
def test_suite():
    setUp()
    XMLConfig("meta.zcml", zope.component)()
    XMLConfig("configure.zcml", zope.annotation)()
    XMLConfig("configure.zcml", zopyx.txng3.core)()
    XMLConfig("configure.zcml", cornerstone.soup.tests)()
    return unittest.TestSuite(
        [
            doctest.DocFileSuite(file, optionflags=optionflags, globs={"interact": interact, "pprint": pprint})
            for file in TESTFILES
        ]
    )
Exemplo n.º 36
0
def baseIntegration(test):
    placelesssetup.setUp(test)
    directlyProvides(IEditorialRating, IRatingType)
    directlyProvides(IUserRating, IRatingType)
    # We use SampleContainers in our tests, so let's make it annotatable
    classImplements(SampleContainer, IAttributeAnnotatable)
    ztapi.provideAdapter(IAttributeAnnotatable, IAnnotations,
                         AttributeAnnotations)
    ztapi.provideAdapter((IRatingCategory, Interface),
                         IRatingManager, RatingCategoryAdapter)
    container = SampleContainer()
    test.globs = {'my_container': container}
Exemplo n.º 37
0
def setUp(test):
    placelesssetup.setUp(test)
    provideInterface("Test content types",
                     ITestContentType, interfaces.IContentTypeType)
    setUpContents()
    component.provideAdapter(
        AnnotationPrincipalPermissionManager, (interface.Interface,))
    component.provideAdapter(TitleBasedNameChooser)
    component.provideHandler(order.itemMoved)
    component.provideAdapter(order.Reordable, provides=interfaces.IOrder)
    component.provideAdapter(ContentSearchableText)
    setup.setUpTestAsModule(test, 'zojax.content.TESTS')
Exemplo n.º 38
0
 def setUp(self):
     placelesssetup.setUp()
     provideInterface('zope.app.tests.test_introspector.I', I)
     provideInterface('zope.app.tests.test_introspector.I2', I2)
     provideInterface('zope.app.tests.test_introspector.I3', I3)
     provideInterface('zope.app.tests.test_introspector.I4', I4)
     provideInterface('zope.app.tests.test_introspector.M1', M1)
     provideInterface('zope.app.tests.test_introspector.M2', M2)
     provideInterface('zope.app.tests.test_introspector.M3', M3)
     provideInterface('zope.app.tests.test_introspector.M4', M4)
     provideInterface('zope.app.tests.test_introspector.ITestClass',
                      ITestClass)
    def setUp(self):
        placelesssetup.setUp(self)

        self.context = stubydoo.double()
        self.adapted = stubydoo.double()

        @zope.component.adapter(None)
        @zope.interface.implementer(interfaces.INewsletterAttributes)
        def newsletter_attributes_adapter(obj):
            return self.adapted

        zope.component.provideAdapter(newsletter_attributes_adapter)
Exemplo n.º 40
0
def setUp(test):
    placelesssetup.setUp(test)
    setup.setUpTraversal()

    zope.component.provideUtility(
        zope.principalannotation.utility.PrincipalAnnotationUtility(),
        zope.principalannotation.interfaces.IPrincipalAnnotationUtility)
    zope.component.provideAdapter(
        zope.principalannotation.utility.annotations,
        adapts=(None,))
    zope.component.provideAdapter(
        PrincipalClipboard)
Exemplo n.º 41
0
def setUp(test):
    placelesssetup.setUp()
    # Register Renderer Components
    ztapi.provideUtility(IFactory, ReStructuredTextSourceFactory,
                         'zope.source.rest')
    ztapi.browserView(IReStructuredTextSource, '',
                      ReStructuredTextToHTMLRenderer)
    # Cheat and register the ReST renderer as the STX one as well.
    ztapi.provideUtility(IFactory, ReStructuredTextSourceFactory,
                         'zope.source.stx')
    ztapi.browserView(IReStructuredTextSource, '',
                      ReStructuredTextToHTMLRenderer)
    setup.setUpTestAsModule(test, 'zope.app.apidoc.doctest')
Exemplo n.º 42
0
    def setUp(self):
        placelesssetup.setUp(self)

        self.metadata = double(language='klingon')

        @zope.component.adapter(None)
        @zope.interface.implementer(ICategorization)
        def metadata(context):
            return self.metadata
        zope.component.provideAdapter(metadata)

        self.context = double(title=u'Content title')
        self.configuration = NullTemplateConfiguration(self.context)
    def setUp(self):
        placelesssetup.setUp(self)
        zope.component.provideUtility(cache_manager, interfaces.ICacheManager)
        zope.component.provideUtility(cache_keys, interfaces.ICacheKeys)
        zope.component.provideAdapter(Cacheable)
        setSite(portal)

        stub(url_opener, 'open').with_args('http://external.com/image.png').\
                and_return(StringIO('the image contents'))
        stub(cache_keys.getKey).with_args('http://external.com/image.png').\
                and_return('=the-cache-key')
        stub(cache_keys.getURL).with_args('=the-cache-key').\
                and_return('http://external.com/image.png')
Exemplo n.º 44
0
def test_suite():
    setUp()
    XMLConfig('meta.zcml', zope.component)()
    XMLConfig('configure.zcml', zope.annotation)()
    XMLConfig('configure.zcml', zopyx.txng3.core)()
    XMLConfig('configure.zcml', cornerstone.soup.tests)()
    return unittest.TestSuite([
        doctest.DocFileSuite(
            file, 
            optionflags=optionflags,
            globs={'interact': interact,
                   'pprint': pprint},
        ) for file in TESTFILES
    ])
Exemplo n.º 45
0
    def setUp(self):
        placelesssetup.setUp(self)
        self.compilation_strategy = double()

        @zope.component.adapter(None, INullTemplateConfiguration)
        @zope.interface.implementer(interfaces.ICompilationStrategy)
        def compilation_strategy(content, config):
            self.compilation_strategy.context = content
            self.compilation_strategy.config = config
            return self.compilation_strategy

        zope.component.provideAdapter(compilation_strategy)
        stub(self.compilation_strategy, 'compile').\
            and_return('Compilation results')
def setUp(test):
    placelesssetup.setUp()
    mock_session = MockSession()
    provideAdapter(lambda x: mock_session, (INotificationRequest, ), ISession)
    provideAdapter(lambda x: mock_session, (INotificationResponse, ), ISession)
    provideAdapter(adaptNotificationRequestToResponse,
                   (INotificationRequest, ), INotificationResponse)

    mock_browser_request = TestRequest()
    provideAdapter(lambda x: mock_browser_request, (INotificationRequest, ),
                   IBrowserRequest)

    test.globs['MockResponse'] = MockHTTPApplicationResponse
    test.globs['structured'] = structured
Exemplo n.º 47
0
def columnSetUp(test):
    placelesssetup.setUp(test)
    component.provideAdapter(
        zope.app.form.browser.TextWidget,
        (zope.schema.interfaces.ITextLine,
         zope.publisher.interfaces.browser.IBrowserRequest,
         ),
        zope.app.form.interfaces.IInputWidget)
    component.provideAdapter(
        zope.app.form.browser.CheckBoxWidget,
        (zope.schema.interfaces.IBool,
         zope.publisher.interfaces.browser.IBrowserRequest,
         ),
        zope.app.form.interfaces.IInputWidget)
    def setUp(self):
        placelesssetup.setUp(self)

        self.document = stubydoo.double()
        self.document.body = u'<p>Test!</p>'
        self.config = stubydoo.double()

        @zope.component.adapter(None)
        @zope.interface.implementer(interfaces.IHTMLBody)
        def body_attribute(doc):
            return stubydoo.double(__unicode__=lambda self:doc.body)

        zope.component.provideAdapter(body_attribute)

        self.compiler = CompilationStrategy(self.document, self.config)
    def setUp(self):
        placelesssetup.setUp(self)

        self.context = stubydoo.double()
        self.adapted = stubydoo.double()

        # This is normally registered during application startup.
        zope.component.provideHandler(zope.component.event.objectEventNotify)

        @zope.component.adapter(None)
        @zope.interface.implementer(interfaces.INewsletterAttributes)
        def newsletter_attributes_adapter(context):
            return self.adapted

        zope.component.provideAdapter(newsletter_attributes_adapter)
Exemplo n.º 50
0
    def setUp(self):
        placelesssetup.setUp(self)
        self.context = double()

        zope.interface.alsoProvides(self.context, IAttributeAnnotatable)

        @zope.component.adapter(IAttributeAnnotatable)
        @zope.interface.implementer(IAnnotations)
        def annotations_adapter(context):
            if hasattr(context, '_annotations'):
                return context._annotations
            context._annotations = {}
            return context._annotations
        zope.component.provideAdapter(annotations_adapter)

        self.templating = Templating(self.context)
Exemplo n.º 51
0
def setUp(test):
    placelesssetup.setUp(test)
    module.setUp(test)
    test.globs['conn'] = testing.getConnection()
    test.globs['DBNAME'] = DBNAME
    testing.cleanDB(test.globs['conn'], test.globs['DBNAME'])
    test.globs['dm'] = datamanager.MongoDataManager(
        test.globs['conn'],
        default_database=test.globs['DBNAME'],
        root_database=test.globs['DBNAME'])

    # silence this, otherwise half-baked objects raise exceptions
    # on trying to __repr__ missing attributes
    test.orig_DEBUG_EXCEPTION_FORMATTER = \
        exceptionformatter.DEBUG_EXCEPTION_FORMATTER
    exceptionformatter.DEBUG_EXCEPTION_FORMATTER = 0
Exemplo n.º 52
0
def test_suite():
    setUp()
    import zope.app.component
    XMLConfig('meta.zcml', zope.app.component)()
    #import Products.Five
    #XMLConfig('meta.zcml', Products.Five)()
    import cornerstone.browser
    XMLConfig('base.zcml', cornerstone.browser)()

    return unittest.TestSuite([
        doctest.DocFileSuite(
            file,
            package="cornerstone.browser",
            optionflags=optionflags,
            globs=dict(interact=interlude.interact, pprint=pprint),
        ) for file in TESTFILES
    ])
    tearDown()
Exemplo n.º 53
0
def remoteSetUp(test):
    placelesssetup.setUp()
    from getpaid.core.interfaces import ITaxUtility
    from getpaid.core.tax import TaxUtility
    provideUtility(TaxUtility(), ITaxUtility)
    import Products.Five
    import getpaid.authorizedotnet
    zcml.load_config('configure.zcml', Products.Five)
    zcml.load_config('configure.zcml', getpaid.authorizedotnet)
    
    login = os.environ.get('AUTHORIZE_DOT_NET_LOGIN')
    key = os.environ.get('AUTHORIZE_DOT_NET_TRANSACTION_KEY')

    if login is None or key is None:
        raise RuntimeError('both AUTHORIZE_DOT_NET_LOGIN and'
                           ' AUTHORIZE_DOT_NET_TRANSACTION_KEY must be'
                           ' provided in order to run the zc.authorizedotnet'
                           ' tests against the Authorize.Net test server.')

    test.globs['LOGIN'] = login
    test.globs['KEY'] = key
Exemplo n.º 54
0
    def setUp(self):
        placelesssetup.setUp(self)

        class CompilationStrategy(object):
            zope.component.adapts(None, ITemplateConfiguration)
            zope.interface.implements(interfaces.ICompilationStrategy)

            def __init__(self, content, config):
                self.context, self.config = content, config

            def compile(self):
                return self.config.html % self.context.body

        class Configuration(object):
            zope.component.adapts(IAttributeAnnotatable)
            zope.interface.implements(ITemplateConfiguration)

            def __init__(self, context):
                self.html = u'html(%s)'

        zope.component.provideAdapter(CompilationStrategy)
        zope.component.provideAdapter(Configuration)
Exemplo n.º 55
0
    def wrapper(*args, **kw):
        __doc__ = '''%s ::

        @param required_zcml callback or iterable of callbacks
        required for setup of configuration needed by fixture
        creation.
        ''' % orig_func.__doc__

        # Setup the placeless stuff that's needed to create a fixture
        setUp()

        # Call any necessary callbacks for setting up ZCML
        callZCML(required_zcml)
        if kw.has_key('required_zcml'):
            zcml = kw.pop('required_zcml')
            callZCML(zcml)

        value = orig_func(*args, **kw)

        # And tear it down
        tearDown()
        return value