Esempio n. 1
0
def test_loading_settings_from_object_with_invalid_path_to_object(
        monkeypatch_pkg_resources):
    """Check that ImportStringError will raise."""

    with pytest.raises(config.ImportStringError):
        settei.get_config('application',
                          'settings_from_object_with_invalid_path_to_object')
Esempio n. 2
0
def test_loading_settings_from_object_with_path_to_object(monkeypatch_pkg_resources):
    """Check that settings were loaded from object with path to object."""

    config = settei.get_config('application', 'settings_from_object_with_path_to_object')

    assert config['ANSWER'] == SettingsHandler.ANSWER
    assert config['DEBUG'] == SettingsHandler.DEBUG
Esempio n. 3
0
def test_environment_from_envvar(monkeypatch_pkg_resources, config_environment):
    """Check that settings were loaded from environment variable."""

    config = settei.get_config('application')

    assert config == dev(default())

    del(os.environ['CONFIG_ENVIRONMENT'])
Esempio n. 4
0
def test_environment_from_envvar(monkeypatch_pkg_resources,
                                 config_environment):
    """Check that settings were loaded from environment variable."""

    config = settei.get_config('application')

    assert config == dev(default())

    del (os.environ['CONFIG_ENVIRONMENT'])
Esempio n. 5
0
def test_loading_settings_from_object_with_path_to_object(
        monkeypatch_pkg_resources):
    """Check that settings were loaded from object with path to object."""

    config = settei.get_config('application',
                               'settings_from_object_with_path_to_object')

    assert config['ANSWER'] == SettingsHandler.ANSWER
    assert config['DEBUG'] == SettingsHandler.DEBUG
Esempio n. 6
0
def test_more_than_one_dependency_injection_specified(
        monkeypatch_pkg_resources):
    """Check that it is impossible to have more that one dependency injection for entry point."""

    with pytest.raises(settei.MoreThanOneDependencyInjection):
        settei.get_config('application', 'live')
Esempio n. 7
0
def test_wrong_config_type(monkeypatch_pkg_resources):
    """Check that WrongConfigTypeError is raising if we are trying to get wrong type of config object."""

    with pytest.raises(settei.WrongConfigTypeError):
        settei.get_config('application', 'wrong_config_object')
Esempio n. 8
0
def test_environment_not_specified(monkeypatch_pkg_resources):
    """Check that EnvironmentNotSpecified is raising if we are trying to get config without specified environment."""
    with pytest.raises(settei.EnvironmentNotSpecified):
        settei.get_config('application')
Esempio n. 9
0
def test_environment_is_missing(monkeypatch_pkg_resources):
    """Check that EnvironmentIsMissing is raising if we are trying to get config with missing environment."""
    with pytest.raises(settei.EnvironmentIsMissing):
        settei.get_config('application', 'missing_environment')
Esempio n. 10
0
def test_more_than_one_dependency_injection_specified(monkeypatch_pkg_resources):
    """Check that it is impossible to have more that one dependency injection for entry point."""

    with pytest.raises(settei.MoreThanOneDependencyInjection):
        settei.get_config('application', 'live')
Esempio n. 11
0
def test_duplicate_entry_point_exception(monkeypatch_pkg_resources_duplicate):
    """Check that DuplicateEntryPoint is raising if list of entry points has several entry points with the same name."""
    with pytest.raises(settei.DuplicateEntryPoint):
        settei.get_config('application', 'default')
Esempio n. 12
0
def test_loading_settings_from_envvar_invalid_path(monkeypatch_pkg_resources):
    """Check that ImportStringError will raise."""

    with pytest.raises(IOError):
        settei.get_config('application', 'settings_from_invalid_path')
Esempio n. 13
0
def test_dev_entry_point(monkeypatch_pkg_resources):
    """Check that we are getting config for dev environment correctly."""
    dev_config = settei.get_config('application', 'dev')

    assert dev_config == dev(default())
Esempio n. 14
0
def test_loading_settings_from_envvar(monkeypatch_pkg_resources):
    """Check that settings were loaded from environment variable."""

    config = settei.get_config('application', 'settings_from_envvar')

    assert config['TEST_KEY'] == TEST_KEY
Esempio n. 15
0
def test_loading_settings_from_envvar_invalid_path(monkeypatch_pkg_resources):
    """Check that ImportStringError will raise."""

    with pytest.raises(IOError):
        settei.get_config('application', 'settings_from_invalid_path')
Esempio n. 16
0
def test_loading_settings_from_object_with_invalid_path_to_object(monkeypatch_pkg_resources):
    """Check that ImportStringError will raise."""

    with pytest.raises(config.ImportStringError):
        settei.get_config('application', 'settings_from_object_with_invalid_path_to_object')
Esempio n. 17
0
def test_environment_not_specified(monkeypatch_pkg_resources):
    """Check that EnvironmentNotSpecified is raising if we are trying to get config without specified environment."""
    with pytest.raises(settei.EnvironmentNotSpecified):
        settei.get_config('application')
Esempio n. 18
0
def test_wrong_config_type(monkeypatch_pkg_resources):
    """Check that WrongConfigTypeError is raising if we are trying to get wrong type of config object."""

    with pytest.raises(settei.WrongConfigTypeError):
        settei.get_config('application', 'wrong_config_object')
Esempio n. 19
0
def test_duplicate_entry_point_exception(monkeypatch_pkg_resources_duplicate):
    """Check that DuplicateEntryPoint is raising if list of entry points has several entry points with the same name."""
    with pytest.raises(settei.DuplicateEntryPoint):
        settei.get_config('application', 'default')
Esempio n. 20
0
def test_dev_entry_point(monkeypatch_pkg_resources):
    """Check that we are getting config for dev environment correctly."""
    dev_config = settei.get_config('application', 'dev')

    assert dev_config == dev(default())
Esempio n. 21
0
def test_loading_settings_from_envvar(monkeypatch_pkg_resources):
    """Check that settings were loaded from environment variable."""

    config = settei.get_config('application', 'settings_from_envvar')

    assert config['TEST_KEY'] == TEST_KEY
Esempio n. 22
0
def test_environment_is_missing(monkeypatch_pkg_resources):
    """Check that EnvironmentIsMissing is raising if we are trying to get config with missing environment."""
    with pytest.raises(settei.EnvironmentIsMissing):
        settei.get_config('application', 'missing_environment')
Esempio n. 23
0
def settings():
    config = get_config('application', 'local')

    return str(config)
Esempio n. 24
0
from settei import get_config

# get config settings for 'application' and environment
# which was specified when running script.py
config = get_config('application')

print config['env']