def use_test_env(): # setup os.environ['CKAN_TESTING'] = 'True' environment.update_config() yield # teardown os.environ.pop('CKAN_TESTING', None)
def plugins_update(): ''' This is run when plugins have been loaded or unloaded and allows us to run any specific code to ensure that the new plugin setting are correctly setup ''' # It is posible for extra SingletonPlugin extensions to be activated if # the file containing them is imported, for example if two or more # extensions are defined in the same file. Therefore we do a sanity # check and disable any that should not be active. for env in PluginGlobals.env_registry.values(): for service in env.services.copy(): if service.__class__ not in _PLUGINS_CLASS: service.deactivate() # Reset CKAN to reflect the currently enabled extensions. import ckan.config.environment as environment environment.update_config()
def test_formencode_uses_locale_default(self): environment.update_config() from ckan.lib.navl.dictization_functions import validate from ckan.lib.navl.validators import not_empty from formencode import validators schema = { "name": [not_empty, text_type], "email": [validators.Email], "email2": [validators.Email], } data = { "name": "fred", "email": "32", "email2": "*****@*****.**", } converted_data, errors = validate(data, schema) eq_({'email': [u'Eine E-Mail-Adresse muss genau ein @-Zeichen enthalten']}, errors)
def test_formencode_uses_locale_default(self): environment.update_config() from ckan.lib.navl.dictization_functions import validate from ckan.lib.navl.validators import not_empty from formencode import validators schema = { "name": [not_empty, unicode], "email": [validators.Email], "email2": [validators.Email], } data = { "name": "fred", "email": "32", "email2": "*****@*****.**", } converted_data, errors = validate(data, schema) eq_({'email': [u'Eine E-Mail-Adresse muss genau ein @-Zeichen enthalten']}, errors)
def test_siteurl_removes_backslash(self): environment.update_config() nosetools.assert_equals(config['ckan.site_url'], 'http://demo.ckan.org')
def test_missing_timezone(): with pytest.raises(CkanConfigurationException): environment.update_config()
def test_siteurl_removes_backslash(ckan_config): environment.update_config() assert ckan_config["ckan.site_url"] == "http://demo.ckan.org"
def test_siteurl_wrong_schema(): with pytest.raises(RuntimeError): environment.update_config()
def test_missing_siteurl(): with pytest.raises(RuntimeError): environment.update_config()