Skip to content

Commit

Permalink
Merge pull request #6 from metaodi/add-helper-error
Browse files Browse the repository at this point in the history
Add HelperError class
  • Loading branch information
amercader committed Feb 14, 2018
2 parents fe0f170 + 4fea393 commit 5efd835
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ckantoolkit/__init__.py
Expand Up @@ -38,6 +38,10 @@ def __getattr__(self, name):
elif name == 'config':
# CKAN < 2.6
from pylons import config as value
elif name == 'HelperError':
class HelperError(Exception):
pass
value = HelperError
else:
raise
setattr(self, name, value) # skip this function next time
Expand Down
1 change: 1 addition & 0 deletions tests/new_ckan/ckan/plugins/toolkit.py
Expand Up @@ -6,3 +6,4 @@
DefaultOrganizationForm = 'six from toolkit'
h = 'seven from toolkit'
config = 'eight from toolkit'
HelperError = 'nine from toolkit'
4 changes: 4 additions & 0 deletions tests/test_new_ckan.py
Expand Up @@ -50,3 +50,7 @@ def test_import_h(self):
def test_import_config(self):
from ckantoolkit import config
assert config == 'eight from toolkit'

def test_import_HelperError(self):
from ckantoolkit import HelperError
assert HelperError == 'nine from toolkit'
5 changes: 5 additions & 0 deletions tests/test_old_ckan.py
Expand Up @@ -56,3 +56,8 @@ def test_import_h_missing_attr(self):
def test_import_config(self):
from ckantoolkit import config
assert config['mock_pylons_config']

def test_import_HelperError(self):
from ckantoolkit import HelperError
error = HelperError()
assert isinstance(error, Exception)

0 comments on commit 5efd835

Please sign in to comment.