[Repoze-dev] Integration testing with imperative configuration
Hi All, 19.3 in the book covers writing integration tests by loading zcml. In a rare lack of symetry for the book, it doesn't cover the same for imperative configuration. Where can I find integration testing examples when using imperative configuration? cheers, Chris ___ Repoze-dev mailing list Repoze-dev@lists.repoze.org http://lists.repoze.org/listinfo/repoze-dev
Re: [Repoze-dev] Integration testing with imperative configuration
On 4/27/10 7:27 AM, Chris Withers wrote: Hi All, 19.3 in the book covers writing integration tests by loading zcml. In a rare lack of symetry for the book, it doesn't cover the same for imperative configuration. Where can I find integration testing examples when using imperative configuration? The docs use a test case like so: class ViewIntegrationTests(unittest.TestCase): def setUp(self): import myapp self.config = Configurator(package=myapp) self.config.begin() self.config.load_zcml('myapp:configure.zcml') def tearDown(self): Clear out the application registry self.config.end() Instead of calling config.load_zcml there, do whatever your application does to configure itself in its run.py (often .scan()), e.g.: class ViewIntegrationTests(unittest.TestCase): def setUp(self): import myapp self.config = Configurator(package=myapp) self.config.begin() self.config.scan() def tearDown(self): Clear out the application registry self.config.end() ___ Repoze-dev mailing list Repoze-dev@lists.repoze.org http://lists.repoze.org/listinfo/repoze-dev
Re: [Repoze-dev] Integration testing with imperative configuration
On 4/27/10 8:41 AM, Chris Withers wrote: Chris McDonough wrote: Instead of calling config.load_zcml there, do whatever your application does to configure itself in its run.py (often .scan()), e.g.: class ViewIntegrationTests(unittest.TestCase): def setUp(self): import myapp self.config = Configurator(package=myapp) self.config.begin() self.config.scan() def tearDown(self): Clear out the application registry self.config.end() Indeed, but that's a bit anti-DRY... I guess this would be an indicator of factoring out the imperative configuration into a function that took a config argument as its only parameter and could be called either form the tests or from the app setup? Sure. The decision to do that is up to the developer. - C ___ Repoze-dev mailing list Repoze-dev@lists.repoze.org http://lists.repoze.org/listinfo/repoze-dev
[Repoze-dev] how to get the response
Hi, I have a question about how to get the response from a request, how to set a cookie and redirect. Is there any working example? Something like that: ppp = request.get_response() ppp.set_cookie('fb_user', value=value, ...) and then redirect to the application url return HTTPFound(location=self.request.application_url) Thanks, davide -- Davide Moro Redomino S.r.l. Largo Valgioie 14, 10146 Torino Italy Tel: +39 0117499875 http://redomino.com ___ Repoze-dev mailing list Repoze-dev@lists.repoze.org http://lists.repoze.org/listinfo/repoze-dev
Re: [Repoze-dev] how to get the response
Ciao Davide, There is not a response already attached to the request, but your instance of HTTPFound *is* a response, so you would just set your cookie there: ppp = HTTPFound(location=request.application_url) ppp.set_cookie('fb_user', value=value, ...) return ppp Chris On Tue, Apr 27, 2010 at 12:28 PM, Davide Moro davide.m...@redomino.com wrote: Hi, I have a question about how to get the response from a request, how to set a cookie and redirect. Is there any working example? Something like that: ppp = request.get_response() ppp.set_cookie('fb_user', value=value, ...) and then redirect to the application url return HTTPFound(location=self.request.application_url) Thanks, davide -- Davide Moro Redomino S.r.l. Largo Valgioie 14, 10146 Torino Italy Tel: +39 0117499875 http://redomino.com ___ Repoze-dev mailing list Repoze-dev@lists.repoze.org http://lists.repoze.org/listinfo/repoze-dev ___ Repoze-dev mailing list Repoze-dev@lists.repoze.org http://lists.repoze.org/listinfo/repoze-dev