示例#1
0
    def test_load_with_existing_env_vars_from_args(self):
        env = Env('ABC')
        os.environ['ABC'] = '456'
        env.load()

        assert env.data['ABC'] == '456'

        del os.environ['ABC']
示例#2
0
    def test_load_with_existing_env_vars(self):
        env = Env(keys=['ABC'])
        os.environ['ABC'] = '456'
        env.load()

        assert env.data['ABC'] == '456'

        del os.environ['ABC']
示例#3
0
    def test_load_with_existing_env_vars_from_args(self):
        env = Env('ABC')
        os.environ['ABC'] = '456'
        env.load()

        assert env.data['ABC'] == '456'

        del os.environ['ABC']
示例#4
0
    def test_load_with_existing_env_vars_from_kwargs(self):
        env = Env(**{'src_abc': 'dest_abc'})
        os.environ['SRC_ABC'] = '456'
        env.load()

        assert 'SRC_ABC' not in env.data
        assert 'DEST_ABC' in env.data
        assert env.data['DEST_ABC'] == '456'

        del os.environ['SRC_ABC']
示例#5
0
    def test_load_with_existing_env_vars_from_kwargs(self):
        env = Env(**{'src_abc': 'dest_abc'})
        os.environ['SRC_ABC'] = '456'
        env.load()

        assert 'SRC_ABC' not in env.data
        assert 'DEST_ABC' in env.data
        assert env.data['DEST_ABC'] == '456'

        del os.environ['SRC_ABC']
示例#6
0
    def test_load_with_non_existing_env_vars(self):
        env = Env(keys=["abc", "easy as"])
        os.environ["ABC"] = "123"

        env.load() 

        assert "ABC" in env.data
        assert "EASY_AS" not in env.data
        assert env.data["ABC"] == "123"

        del os.environ['ABC']
示例#7
0
    def test_load_with_provided_overriding_keys(self):
        env = Env(keys=["abc"])

        os.environ["ABC"] = "123"
        os.environ["EASY_AS"] = "do re mi"

        env.load(keys=["easy as"])

        assert "ABC" in env.data
        assert "EASY_AS" in env.data
        assert env.data["ABC"] == "123"
        assert env.data["EASY_AS"] == "do re mi"
示例#8
0
    def test_load_with_non_existing_env_vars_from_args(self):
        env = Env(**{"src_abc": "dest_abc", "src_easy_as": "dest_easy_as"})

        os.environ["SRC_ABC"] = "123"
        env.load() 

        assert "SRC_ABC" not in env.data
        assert "DEST_ABC" in env.data
        assert env.data["DEST_ABC"] == "123"

        assert "SRC_EASY_AS" not in env.data
        assert "DEST_EASY_AS" not in env.data

        del os.environ['SRC_ABC']
示例#9
0
    def test_load_with_non_existing_env_vars_from_args(self):
        env = Env(**{"src_abc": "dest_abc", "src_easy_as": "dest_easy_as"})

        os.environ["SRC_ABC"] = "123"
        env.load()

        assert "SRC_ABC" not in env.data
        assert "DEST_ABC" in env.data
        assert env.data["DEST_ABC"] == "123"

        assert "SRC_EASY_AS" not in env.data
        assert "DEST_EASY_AS" not in env.data

        del os.environ['SRC_ABC']