Use config from ckan.plugins.toolkit on tests
This commit is contained in:
parent
68dc704d6b
commit
1030939052
|
@ -34,9 +34,6 @@ class ActionsTest(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
|
||||||
# Load the mocks
|
# Load the mocks
|
||||||
self._config = actions.config
|
|
||||||
actions.config = MagicMock()
|
|
||||||
|
|
||||||
self._importlib = actions.importlib
|
self._importlib = actions.importlib
|
||||||
actions.importlib = MagicMock()
|
actions.importlib = MagicMock()
|
||||||
|
|
||||||
|
@ -48,7 +45,6 @@ class ActionsTest(unittest.TestCase):
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
# Unmock
|
# Unmock
|
||||||
actions.config = self._config
|
|
||||||
actions.importlib = self._importlib
|
actions.importlib = self._importlib
|
||||||
actions.plugins = self._plugins
|
actions.plugins = self._plugins
|
||||||
actions.db = self._db
|
actions.db = self._db
|
||||||
|
@ -66,7 +62,7 @@ class ActionsTest(unittest.TestCase):
|
||||||
def test_class_cannot_be_loaded(self, class_path, class_name, path_exist, class_exist, expected_error):
|
def test_class_cannot_be_loaded(self, class_path, class_name, path_exist, class_exist, expected_error):
|
||||||
class_package = class_path
|
class_package = class_path
|
||||||
class_package += ':' + class_name if class_name else ''
|
class_package += ':' + class_name if class_name else ''
|
||||||
actions.config = {PARSER_CONFIG_PROP: class_package}
|
actions.plugins.toolkit.config = {PARSER_CONFIG_PROP: class_package}
|
||||||
|
|
||||||
# Recover exception
|
# Recover exception
|
||||||
actions.plugins.toolkit.ValidationError = self._plugins.toolkit.ValidationError
|
actions.plugins.toolkit.ValidationError = self._plugins.toolkit.ValidationError
|
||||||
|
@ -93,7 +89,7 @@ class ActionsTest(unittest.TestCase):
|
||||||
def configure_mocks(self, parse_result, datasets_not_found=[], not_updatable_datasets=[],
|
def configure_mocks(self, parse_result, datasets_not_found=[], not_updatable_datasets=[],
|
||||||
allowed_users=None, creator_user={'id': '1234', 'name': 'ckan'}):
|
allowed_users=None, creator_user={'id': '1234', 'name': 'ckan'}):
|
||||||
|
|
||||||
actions.config = {PARSER_CONFIG_PROP: 'valid.path:%s' % CLASS_NAME}
|
actions.plugins.toolkit.config = {PARSER_CONFIG_PROP: 'valid.path:%s' % CLASS_NAME}
|
||||||
|
|
||||||
# Configure mocks
|
# Configure mocks
|
||||||
parser_instance = MagicMock()
|
parser_instance = MagicMock()
|
||||||
|
|
|
@ -33,12 +33,11 @@ class HelpersTest(unittest.TestCase):
|
||||||
|
|
||||||
self._tk = helpers.tk
|
self._tk = helpers.tk
|
||||||
helpers.tk = MagicMock()
|
helpers.tk = MagicMock()
|
||||||
|
helpers.tk.config = {}
|
||||||
|
|
||||||
self._db = helpers.db
|
self._db = helpers.db
|
||||||
helpers.db = MagicMock()
|
helpers.db = MagicMock()
|
||||||
|
|
||||||
self._config = helpers.config
|
|
||||||
helpers.config = {}
|
|
||||||
|
|
||||||
self._request = helpers.request
|
self._request = helpers.request
|
||||||
helpers.request = MagicMock()
|
helpers.request = MagicMock()
|
||||||
|
@ -47,7 +46,6 @@ class HelpersTest(unittest.TestCase):
|
||||||
helpers.model = self._model
|
helpers.model = self._model
|
||||||
helpers.tk = self._tk
|
helpers.tk = self._tk
|
||||||
helpers.db = self._db
|
helpers.db = self._db
|
||||||
helpers.config = self._config
|
|
||||||
helpers.request = self._request
|
helpers.request = self._request
|
||||||
|
|
||||||
@parameterized.expand([
|
@parameterized.expand([
|
||||||
|
@ -135,7 +133,7 @@ class HelpersTest(unittest.TestCase):
|
||||||
])
|
])
|
||||||
def test_show_acquire_url_on_create(self, config_value, expected_value):
|
def test_show_acquire_url_on_create(self, config_value, expected_value):
|
||||||
if config_value is not None:
|
if config_value is not None:
|
||||||
helpers.config['ckan.privatedatasets.show_acquire_url_on_create'] = config_value
|
helpers.tk.config['ckan.privatedatasets.show_acquire_url_on_create'] = config_value
|
||||||
|
|
||||||
# Call the function
|
# Call the function
|
||||||
self.assertEquals(expected_value, helpers.show_acquire_url_on_create())
|
self.assertEquals(expected_value, helpers.show_acquire_url_on_create())
|
||||||
|
@ -147,7 +145,7 @@ class HelpersTest(unittest.TestCase):
|
||||||
])
|
])
|
||||||
def test_show_acquire_url_on_edit(self, config_value, expected_value):
|
def test_show_acquire_url_on_edit(self, config_value, expected_value):
|
||||||
if config_value is not None:
|
if config_value is not None:
|
||||||
helpers.config['ckan.privatedatasets.show_acquire_url_on_edit'] = config_value
|
helpers.tk.config['ckan.privatedatasets.show_acquire_url_on_edit'] = config_value
|
||||||
|
|
||||||
# Call the function
|
# Call the function
|
||||||
self.assertEquals(expected_value, helpers.show_acquire_url_on_edit())
|
self.assertEquals(expected_value, helpers.show_acquire_url_on_edit())
|
||||||
|
|
Loading…
Reference in New Issue