Example #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')
Example #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
Example #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'])
Example #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'])
Example #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
Example #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')
Example #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')
Example #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')
Example #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')
Example #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')
Example #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')
Example #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')
Example #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())
Example #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
Example #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')
Example #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')
Example #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')
Example #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')
Example #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')
Example #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())
Example #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
Example #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')
Example #23
0
def settings():
    config = get_config('application', 'local')

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