Ejemplo n.º 1
0
    def test_as_dict(self, mock_envfile):
        settings = Settings(env_prefix="PREFIX_")
        settings.load_dotenv_file(mock_envfile)

        as_dict = settings.as_dict()
        assert as_dict == settings._config
        assert isinstance(as_dict, dict)
Ejemplo n.º 2
0
    def test_load_envfile_with_prefix_strips_out_prefix(self, mock_envfile):
        settings = Settings(env_prefix="PREFIX_")
        settings.load_dotenv_file(mock_envfile)

        with pytest.raises(AttributeError):
            settings.PREFIX_DEBUG

        assert settings.DEBUG is True
Ejemplo n.º 3
0
    def test_load_envfile_with_prefix(self, mock_envfile):
        settings = Settings(env_prefix="PREFIX_")
        settings.load_dotenv_file(mock_envfile)

        assert settings.DEBUG is True
        assert settings.ESCAPED_HASH == {"dict": "test"}
        assert settings.UNESCAPED_HASH == {"dict": "test"}
        assert settings.MULTILINE_KEY == (
            "===BEGIN PUBLIC CERTIFICATE=== \n" " it is a certificate value \n" "===END PUBLIC CERTIFICATE==="
        )
Ejemplo n.º 4
0
    def test_prefix_gets_stripped_once_only(self, mock_envfile):
        settings = Settings(env_prefix="PREFIX_")
        settings.load_dotenv_file(mock_envfile)

        assert settings.SOME_KEY_PREFIX_REPEATED == "nested"
Ejemplo n.º 5
0
    def test_load_envfile_does_not_load_unprefixed_vars(self, mock_envfile):
        settings = Settings(env_prefix="PREFIX_")
        settings.load_dotenv_file(mock_envfile)

        with pytest.raises(AttributeError):
            settings.USER