[ckan-changes] commit/ckan: dread: [tests]: DGU#1149 Extended pylons setup for dgu test.
Bitbucket
commits-noreply at bitbucket.org
Fri Jun 24 08:39:10 UTC 2011
1 new changeset in ckan:
http://bitbucket.org/okfn/ckan/changeset/f0bd3b867adb/
changeset: f0bd3b867adb
user: dread
date: 2011-06-24 10:37:47
summary: [tests]: DGU#1149 Extended pylons setup for dgu test.
affected #: 2 files (573 bytes)
--- a/ckan/tests/html_check.py Thu Jun 23 16:45:20 2011 +0100
+++ b/ckan/tests/html_check.py Fri Jun 24 09:37:47 2011 +0100
@@ -10,7 +10,12 @@
def named_div(self, div_name, html):
'strips html to just the <div id="DIV_NAME"> section'
- the_html = html.body.decode('utf8')
+ if isinstance(html, paste.fixture.TestResponse):
+ the_html = html.body.decode('utf8')
+ elif isinstance(html, basestring):
+ the_html = html
+ else:
+ raise NotImplementedError
start_div = the_html.find(u'<div id="%s"' % div_name)
end_div = the_html.find(u'<!-- #%s -->' % div_name)
if end_div == -1:
--- a/ckan/tests/pylons_controller.py Thu Jun 23 16:45:20 2011 +0100
+++ b/ckan/tests/pylons_controller.py Fri Jun 24 09:37:47 2011 +0100
@@ -8,12 +8,18 @@
from unittest import TestCase
from paste.registry import Registry
import pylons
-from pylons.util import ContextObj
+from pylons.util import AttribSafeContextObj
+import ckan.lib.app_globals as app_globals
from pylons.controllers.util import Request, Response
+from routes.util import URLGenerator
+from ckan.config.routing import make_map
from ckan.tests import *
from ckan.lib.cli import MockTranslator
+class TestSession(dict):
+ def save(self):
+ pass
class PylonsTestCase(object):
"""A basic test case which allows access to pylons.c and pylons.request.
@@ -23,9 +29,11 @@
cls.registry=Registry()
cls.registry.prepare()
- cls.context_obj=ContextObj()
+ cls.context_obj=AttribSafeContextObj()
cls.registry.register(pylons.c, cls.context_obj)
- pylons.c.errors = None
+
+ 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.registry.register(pylons.request, cls.request_obj)
@@ -37,4 +45,6 @@
cls.registry.register(pylons.buffet, cls.buffet)
cls.registry.register(pylons.response, Response())
- cls.registry.register(pylons.url, None)
+ mapper = make_map()
+ cls.registry.register(pylons.url, URLGenerator(mapper, {}))
+ cls.registry.register(pylons.session, TestSession())
Repository URL: https://bitbucket.org/okfn/ckan/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
More information about the ckan-changes
mailing list