Example #1
0
def use_test_env():
    # setup
    os.environ['CKAN_TESTING'] = 'True'
    environment.update_config()

    yield

    # teardown
    os.environ.pop('CKAN_TESTING', None)
Example #2
0
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()
Example #3
0
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()
Example #4
0
    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)
Example #5
0
    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)
Example #6
0
 def test_siteurl_removes_backslash(self):
     environment.update_config()
     nosetools.assert_equals(config['ckan.site_url'],
                             'http://demo.ckan.org')
Example #7
0
def test_missing_timezone():
    with pytest.raises(CkanConfigurationException):
        environment.update_config()
Example #8
0
def test_siteurl_removes_backslash(ckan_config):
    environment.update_config()
    assert ckan_config["ckan.site_url"] == "http://demo.ckan.org"
Example #9
0
def test_siteurl_wrong_schema():
    with pytest.raises(RuntimeError):
        environment.update_config()
Example #10
0
def test_missing_siteurl():
    with pytest.raises(RuntimeError):
        environment.update_config()