From 5f39f8677b15556e6674fe3ac713ea83cc0334bc Mon Sep 17 00:00:00 2001 From: David Read Date: Thu, 10 May 2012 15:49:25 +0100 Subject: [PATCH] Extend test pylons environment to cope with DGU tests. --- ckan/tests/pylons_controller.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/ckan/tests/pylons_controller.py b/ckan/tests/pylons_controller.py index d3ac911b2c5..b23b93cf866 100644 --- a/ckan/tests/pylons_controller.py +++ b/ckan/tests/pylons_controller.py @@ -17,10 +17,13 @@ from ckan.tests import * from ckan.lib.cli import MockTranslator -class TestSession(dict): +class TestPylonsSession(dict): + last_accessed = None + def save(self): pass + class PylonsTestCase(object): """A basic test case which allows access to pylons.c and pylons.request. """ @@ -35,7 +38,7 @@ def setup_class(cls): cls.app_globals_obj = app_globals.Globals() cls.registry.register(pylons.g, cls.app_globals_obj) - cls.request_obj=Request(dict(HTTP_HOST="nohost")) + cls.request_obj=Request(dict(HTTP_HOST="nohost", REQUEST_METHOD="GET")) cls.registry.register(pylons.request, cls.request_obj) cls.translator_obj=MockTranslator() @@ -47,7 +50,7 @@ def setup_class(cls): cls.registry.register(pylons.response, Response()) mapper = make_map() cls.registry.register(pylons.url, URLGenerator(mapper, {})) - cls.registry.register(pylons.session, TestSession()) + cls.registry.register(pylons.session, TestPylonsSession()) # Templates often want to find out the request's routes info, so put # some dummy values into the routes_dict, so the templates that do @@ -56,6 +59,7 @@ def setup_class(cls): 'action': 'test-action', 'controller': 'test-package::', }}) + pylons.c.environ = pylons.request.environ @classmethod def teardown_class(cls):