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')
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
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'])
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'])
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
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')
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')
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')
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')
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')
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')
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')
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())
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
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')
def settings(): config = get_config('application', 'local') return str(config)
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']