Skip to content

Commit

Permalink
Fix _load_plugins syntax to load extension templates
Browse files Browse the repository at this point in the history
  • Loading branch information
David Read committed Aug 16, 2019
1 parent 9a80e29 commit d61d5d5
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 25 deletions.
7 changes: 5 additions & 2 deletions ckan/tests/helpers.py
Expand Up @@ -198,9 +198,12 @@ def setup_class(cls):
# Make a copy of the Pylons config, so we can restore it in teardown.
cls._original_config = dict(config)
cls._apply_config_changes(config)
try:
config['ckan.plugins'] = ' '.join(cls._load_plugins)
del cls._test_app # reload with the new plugins
except AttributeError:
pass
cls._get_test_app()
for plugin in getattr(cls, '_load_plugins', []):
p.load(plugin)

@classmethod
def _apply_config_changes(cls, cfg):
Expand Down
3 changes: 2 additions & 1 deletion ckanext/datastore/tests/test_db.py
Expand Up @@ -195,7 +195,8 @@ def datastore_job(res_id, value):
A background job that uses the Datastore.
'''
app = helpers._get_test_app()
p.load('datastore')
if not p.plugin_loaded(u'datastore'):
p.load('datastore')
data = {
'resource_id': res_id,
'method': 'insert',
Expand Down
10 changes: 1 addition & 9 deletions ckanext/example_iconfigurer/tests/test_example_iconfigurer.py
Expand Up @@ -8,15 +8,7 @@

class TestExampleIConfigurer(helpers.FunctionalTestBase):

@classmethod
def setup_class(cls):
super(TestExampleIConfigurer, cls).setup_class()
plugins.load('example_iconfigurer')

@classmethod
def teardown_class(cls):
plugins.unload('example_iconfigurer')
super(TestExampleIConfigurer, cls).teardown_class()
_load_plugins = ['example_iconfigurer']

def test_template_renders(self):
'''Our controller renders the extension's config template.'''
Expand Down
14 changes: 1 addition & 13 deletions ckanext/example_idatasetform/tests/test_controllers.py
Expand Up @@ -22,19 +22,7 @@ def _get_package_edit_page(app, package_name):


class TestPackageController(helpers.FunctionalTestBase):
@classmethod
def _apply_config_changes(cls, cfg):
cfg['ckan.plugins'] = 'example_idatasetform'

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

@classmethod
def teardown_class(cls):
if plugins.plugin_loaded('example_idatasetform'):
plugins.unload('example_idatasetform')
super(TestPackageController, cls).teardown_class()
_load_plugins = ['example_idatasetform']

def test_edit_converted_extra_field(self):
dataset = factories.Dataset(custom_text='foo')
Expand Down

0 comments on commit d61d5d5

Please sign in to comment.