Skip to content

Commit

Permalink
Fix reading configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
avdata99 committed Feb 5, 2021
1 parent 531d20c commit d86bbfe
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion ckanext/datagovcatalog/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def before_view(self, pkg_dict):

# Add tracking information just for datasets
if pkg_dict.get('type', 'dataset') == 'dataset':
if config.get('ckanext.datagovcatalog.add_packages_tracking_info', True):
if toolkit.asbool(config.get('ckanext.datagovcatalog.add_packages_tracking_info', True)):
# add tracking information.
# CKAN by default hide tracking info for datasets

Expand Down
22 changes: 20 additions & 2 deletions ckanext/datagovcatalog/tests/test_before_view.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from nose.tools import assert_equal
from nose.tools import assert_equal, assert_not_in
from ckanext.datagovcatalog.helpers.packages import update_tracking_info_to_package
from ckan.tests import helpers


class TestOverridePackage():
Expand Down Expand Up @@ -49,4 +50,21 @@ def test_override_package(self):
assert_equal(resource['tracking_summary'], 'tracking info 3')
asserts += 1

assert_equal(asserts, 3)
assert_equal(asserts, 3)

def _create_dataset(self):
""" create the required datasets to test """
self.org = ckan_factories.Organization()
self.dataset = ckan_factories.Dataset(owner_org=self.org['id'])

@helpers.change_config('ckanext.datagovcatalog.add_packages_tracking_info', 'false')
def test_disable_tracking(self):
self._create_dataset()
context = {'ignore_auth': True}
dataset = helpers.call_action(
"package_show",
context=context,
id=self.dataset['name']
)

assert_not_in('tracking_summary', dataset)

0 comments on commit d86bbfe

Please sign in to comment.