Skip to content

Commit

Permalink
add logic to check if 'find_controller' is allready patched, test_vie…
Browse files Browse the repository at this point in the history
…w rewrite
  • Loading branch information
tino097 committed Aug 31, 2018
1 parent 90daf5c commit e1a3d05
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
7 changes: 6 additions & 1 deletion ckan/config/environment.py
Expand Up @@ -35,6 +35,8 @@
# Suppress benign warning 'Unbuilt egg for setuptools'
warnings.simplefilter('ignore', UserWarning)

monkey_patched = False


def load_environment(global_conf, app_conf):
"""
Expand Down Expand Up @@ -65,7 +67,10 @@ def find_controller(self, controller):
self.controller_classes[controller] = mycontroller
return mycontroller
return find_controller_generic(self, controller)
PylonsApp.find_controller = find_controller
global monkey_patched
if not monkey_patched:
PylonsApp.find_controller = find_controller
monkey_patched = True

os.environ['CKAN_CONFIG'] = global_conf['__file__']

Expand Down
13 changes: 6 additions & 7 deletions ckanext/imageview/tests/test_view.py
Expand Up @@ -11,21 +11,20 @@
class TestImageView(helpers.FunctionalTestBase):

@classmethod
def setup_class(cls):
def _apply_config_changes(cls, cfg):
cfg['ckan.plugins'] = 'image_view'

@classmethod
def setup_class(cls):
super(TestImageView, cls).setup_class()

if not p.plugin_loaded('image_view'):
p.load('image_view')

@classmethod
def teardown_class(cls):
p.unload('image_view')
if p.plugin_loaded('example_idatasetform'):
p.unload('example_idatasetform')

super(TestImageView, cls).teardown_class()

helpers.reset_db()

@helpers.change_config('ckan.views.default_views', '')
def test_view_shown_on_resource_page_with_image_url(self):
app = self._get_test_app()
Expand Down

0 comments on commit e1a3d05

Please sign in to comment.