def test_load_env_to_os(env_inst: Env): env_key = "CWAS_TEST" env_value = "HELLO" env_inst.set_env(env_key, env_value) env_inst.save() env_inst.load_env_to_os() assert os.getenv(env_key) == env_value env_inst.get_path().unlink() os.environ.pop(env_key)
def test_env_save(env_inst: Env): env_key = "TEST" expected = "Hello!" env_inst.set_env(env_key, expected) env_inst.save() cwas_env_path = env_inst.get_path() with cwas_env_path.open() as env_file: env_line = env_file.read() env_line = env_line.strip() assert env_line == "TEST=Hello!" env_inst.get_path().unlink()
def test_env_singleton(cwas_env_path: Path): env1 = Env() env2 = Env() assert env1 is env2 new_env_path = Path(str(cwas_env_path) + "_new") env3 = Env(new_env_path) env4 = Env() assert env1 is env3 assert env1 is env4 assert env1.get_path() is new_env_path env1.set_path(cwas_env_path)
def test_env_init(env_inst: Env, cwas_env_path: Path): assert env_inst.get_path() is cwas_env_path assert isinstance(env_inst.env, OrderedDict)