Test evironment configuration
This commit is contained in:
parent
d98a5e4831
commit
2b8ef43dee
|
@ -1,6 +1,7 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
# Copyright (c) 2014 CoNWeT Lab., Universidad Politécnica de Madrid
|
# Copyright (c) 2014 CoNWeT Lab., Universidad Politécnica de Madrid
|
||||||
|
# Copyright (c) 2018 Future Internet Consulting and Development Solutions S.L.
|
||||||
|
|
||||||
# This file is part of CKAN Private Dataset Extension.
|
# This file is part of CKAN Private Dataset Extension.
|
||||||
|
|
||||||
|
@ -20,7 +21,7 @@
|
||||||
import unittest
|
import unittest
|
||||||
import ckanext.privatedatasets.helpers as helpers
|
import ckanext.privatedatasets.helpers as helpers
|
||||||
|
|
||||||
from mock import MagicMock
|
from mock import patch, MagicMock
|
||||||
from parameterized import parameterized
|
from parameterized import parameterized
|
||||||
|
|
||||||
|
|
||||||
|
@ -127,26 +128,60 @@ class HelpersTest(unittest.TestCase):
|
||||||
helpers.tk.check_access.assert_called_once_with('package_show', context, package)
|
helpers.tk.check_access.assert_called_once_with('package_show', context, package)
|
||||||
|
|
||||||
@parameterized.expand([
|
@parameterized.expand([
|
||||||
(None, False),
|
(None, False, None),
|
||||||
('True', True),
|
('True', True, None),
|
||||||
('False', False)
|
('False', False, None),
|
||||||
|
('afa ', False, None),
|
||||||
|
(True, True, None),
|
||||||
|
(False, False, None),
|
||||||
|
(False, True , 'true'),
|
||||||
|
(False, True , 'on'),
|
||||||
|
(False, True , '1'),
|
||||||
|
(True, False, '0'),
|
||||||
|
(True, False, 'off'),
|
||||||
|
(True, False, 'fAlsE'),
|
||||||
|
(True, False, 'fAlsE'),
|
||||||
])
|
])
|
||||||
def test_show_acquire_url_on_create(self, config_value, expected_value):
|
@patch("ckanext.privatedatasets.helpers.os.environ", new={})
|
||||||
|
def test_show_acquire_url_on_create(self, config_value, expected_value, env_val):
|
||||||
|
# {} is shared between tests, so we have clear it each time
|
||||||
|
helpers.os.environ.clear()
|
||||||
|
|
||||||
if config_value is not None:
|
if config_value is not None:
|
||||||
helpers.tk.config['ckan.privatedatasets.show_acquire_url_on_create'] = config_value
|
helpers.tk.config['ckan.privatedatasets.show_acquire_url_on_create'] = config_value
|
||||||
|
|
||||||
|
if env_val:
|
||||||
|
helpers.os.environ['CKAN_PRIVATEDATASETS_SHOW_ACQUIRE_URL_ON_CREATE'] = env_val
|
||||||
|
|
||||||
# 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())
|
||||||
|
|
||||||
@parameterized.expand([
|
@parameterized.expand([
|
||||||
(None, False),
|
(None, False, None),
|
||||||
('True', True),
|
('True', True, None),
|
||||||
('False', False)
|
(' tRUe', True, None),
|
||||||
|
('False', False, None),
|
||||||
|
(True, True, None),
|
||||||
|
(False, False, None),
|
||||||
|
(False, True , 'trUe'),
|
||||||
|
(False, True , 'on'),
|
||||||
|
(False, True , '1'),
|
||||||
|
(True, False, '0'),
|
||||||
|
(True, False, 'off'),
|
||||||
|
(True, False, 'fAlsE'),
|
||||||
|
(True, False, 'potato'),
|
||||||
])
|
])
|
||||||
def test_show_acquire_url_on_edit(self, config_value, expected_value):
|
@patch("ckanext.privatedatasets.helpers.os.environ", new={})
|
||||||
|
def test_show_acquire_url_on_edit(self, config_value, expected_value, env_val):
|
||||||
|
# {} is shared between tests, so we have clear it each time
|
||||||
|
helpers.os.environ.clear()
|
||||||
|
|
||||||
if config_value is not None:
|
if config_value is not None:
|
||||||
helpers.tk.config['ckan.privatedatasets.show_acquire_url_on_edit'] = config_value
|
helpers.tk.config['ckan.privatedatasets.show_acquire_url_on_edit'] = config_value
|
||||||
|
|
||||||
|
if env_val:
|
||||||
|
helpers.os.environ['CKAN_PRIVATEDATASETS_SHOW_ACQUIRE_URL_ON_EDIT'] = env_val
|
||||||
|
|
||||||
# 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