Skip to content

Commit

Permalink
Revert "Allow to modify the configuration of the test app"
Browse files Browse the repository at this point in the history
This reverts commit 5d70f30.
  • Loading branch information
amercader committed Jun 9, 2016
1 parent 3298f69 commit 0d07630
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
11 changes: 4 additions & 7 deletions ckan/tests/helpers.py
Expand Up @@ -158,23 +158,20 @@ def flask_app(self):
return self._flask_app


def _get_test_app(config_overrides=None):
def _get_test_app():
'''Return a webtest.TestApp for CKAN, with legacy templates disabled.
For functional tests that need to request CKAN pages or post to the API.
Unit tests shouldn't need this.
'''
_config = config.copy()
_config['ckan.legacy_templates'] = False
if config_overrides and isinstance(config_overrides, dict):
_config.update(config_overrides)

app = ckan.config.middleware.make_app(_config['global_conf'], **_config)
config['ckan.legacy_templates'] = False
app = ckan.config.middleware.make_app(config['global_conf'], **config)

# As we are setting SERVER_NAME, Flask needs the HTTP_HOST header to match
# it otherwise the route mapper does not work (returns 404)
parts = urlparse.urlparse(_config.get('ckan.site_url'))
parts = urlparse.urlparse(config.get('ckan.site_url'))
extra_environ = {'HTTP_HOST': str(parts.netloc)}

app = CKANTestApp(app, extra_environ)
Expand Down
14 changes: 11 additions & 3 deletions ckan/tests/lib/test_helpers.py
Expand Up @@ -5,6 +5,7 @@
import tzlocal
from babel import Locale

from pylons import config
import ckan.lib.helpers as h
import ckan.plugins as p
import ckan.exceptions
Expand All @@ -22,9 +23,10 @@ class BaseUrlFor(object):
@classmethod
def setup_class(cls):

cls.app = helpers._get_test_app(config_overrides={
'ckan.site_url': 'http://example.com'
})
# Make a copy of the Pylons config, so we can restore it in teardown.
cls._original_config = dict(config)
config['ckan.site_url'] = 'http://example.com'
cls.app = helpers._get_test_app()

def setup(self):

Expand All @@ -35,6 +37,12 @@ def teardown(self):

self.request_context.pop()

@classmethod
def teardown_class(cls):
# Restore the config to its original values
config.clear()
config.update(cls._original_config)


class TestHelpersUrlForStatic(BaseUrlFor):

Expand Down

0 comments on commit 0d07630

Please sign in to comment.