Exemplo 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')
Exemplo 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
Exemplo 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'])
Exemplo 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'])
Exemplo 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
Exemplo 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')
Exemplo 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')
Exemplo 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')
Exemplo 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')
Exemplo 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')
Exemplo 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')
Exemplo 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')
Exemplo 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())
Exemplo 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
Exemplo 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')
Exemplo 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')
Exemplo 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')
Exemplo 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')
Exemplo 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')
Exemplo 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())
Exemplo 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
Exemplo 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')
Exemplo n.º 23
0
def settings():
    config = get_config('application', 'local')

    return str(config)
Exemplo 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']