[Grok-dev] Testing and events
Christian Klinger
cklinger at novareto.de
Wed Apr 11 05:27:39 UTC 2012
Hi Noe,
you have to call in notify not the interface of the event, you have to
call the event itself. This works in my applications:
def test_event(self):
import grok
root = self.layer.getRootFolder()
root['app'] = app = Grokbackground()
grok.notify(grok.ApplicationInitializedEvent(app))
You can access the app in the subscriber via event.object.
@grok.subscribe(grok.IApplicationInitializedEvent)
def handle_it(event):
print event.object
HTH Christian
Noe Nieto schrieb:
> I'm doing integration testing and my app has an event subscription to
> grok.IApplicationInitializedEvent.
>
> When setting up my layer I'm doing the following (layer is
> zope.fanstatic.testing.ZopeFanstaticBrowserLayer):
>
> def setUp(self):
> #Add test app
> from consworks.app import Consworks
> import grok
> self.root = self.layer.getRootFolder()
> self.root['app'] = Consworks()
> grok.notify(grok.IApplicationInitializedEvent)
>
>
> But the handler for IApplicationInitializedEvent is not being called.
> What else do I need to do to make it work?
>
> --
> ---
> Noe Nieto
> NNieto Consulting Services
> M: nnieto at noenieto.com <mailto:nnieto at noenieto.com>
> W: http://noenieto.com
> T: @tzicatl <https://twitter.com/#%21/tzicatl>
> Li: Perfil en LinkedIn <http://www.linkedin.com/profile/view?id=84300665>
>
> _______________________________________________
> Grok-dev mailing list
> Grok-dev at zope.org
> https://mail.zope.org/mailman/listinfo/grok-dev
More information about the Grok-dev
mailing list