Skip to content

Commit

Permalink
Extend test pylons environment to cope with DGU tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
David Read committed May 10, 2012
1 parent 2c745cd commit 5f39f86
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions ckan/tests/pylons_controller.py
Expand Up @@ -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.
"""
Expand All @@ -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()
Expand All @@ -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
Expand All @@ -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):
Expand Down

0 comments on commit 5f39f86

Please sign in to comment.