How to use the rele.config.Config function in rele

To help you get started, we’ve selected a few rele examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mercadona / rele / tests / test_config.py View on Github external
def test_parses_all_keys(self, project_id, custom_encoder):
        settings = {
            "APP_NAME": "rele",
            "SUB_PREFIX": "rele",
            "GC_PROJECT_ID": project_id,
            "GC_CREDENTIALS_PATH": "tests/dummy-pub-sub-credentials.json",
            "MIDDLEWARE": ["rele.contrib.DjangoDBMiddleware"],
            "ENCODER": custom_encoder,
        }

        config = Config(settings)

        assert config.app_name == "rele"
        assert config.sub_prefix == "rele"
        assert config.gc_project_id == project_id
        assert isinstance(config.credentials, service_account.Credentials)
        assert config.middleware == ["rele.contrib.DjangoDBMiddleware"]
github mercadona / rele / tests / test_config.py View on Github external
def test_sets_defaults_pulled_from_env(self, monkeypatch, project_id):
        settings = {}

        config = Config(settings)

        assert config.app_name is None
        assert config.sub_prefix is None
        assert config.gc_project_id == "rele-test"
        assert isinstance(config.credentials, google.oauth2.service_account.Credentials)
        assert config.middleware == ["rele.contrib.LoggingMiddleware"]
        assert config.encoder == json.JSONEncoder
github mercadona / rele / tests / test_config.py View on Github external
def test_sets_defaults(self):
        settings = {}

        config = Config(settings)

        assert config.app_name is None
        assert config.sub_prefix is None
        assert config.gc_project_id is None
        assert config.credentials is None
        assert config.middleware == ["rele.contrib.LoggingMiddleware"]
        assert config.encoder == json.JSONEncoder
github mercadona / rele / tests / test_config.py View on Github external
def test_inits_service_account_creds_when_credential_path_given(self, project_id):
        settings = {
            "GC_PROJECT_ID": project_id,
            "GC_CREDENTIALS_PATH": "tests/dummy-pub-sub-credentials.json",
        }

        config = Config(settings)

        assert config.gc_project_id == project_id
        assert isinstance(config.credentials, google.oauth2.service_account.Credentials)
        assert config.credentials.project_id == "rele-test"
github mercadona / rele / rele / config.py View on Github external
def setup(setting=None, **kwargs):
    if setting is None:
        setting = {}

    config = Config(setting)
    init_global_publisher(config)
    register_middleware(config, **kwargs)
    return config