Skip to content

Commit

Permalink
feat(tests): add test for PathConfig class in hyfi.env module
Browse files Browse the repository at this point in the history
  • Loading branch information
entelecheia committed Jun 12, 2023
1 parent 4f49f2f commit ca87ba4
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/hyfi/env.test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from hyfi.env import PathConfig
from hyfi.utils.env import expand_posix_vars
from pathlib import Path


def test_path_config():
config = PathConfig()
print(config.dict())
# Test that the default values are set correctly
assert config.config_name == "__init__"
assert config.home == expand_posix_vars("$HOME")
assert config.global_workspace_root == expand_posix_vars("$HOME/.hyfi")
assert config.global_data_root == expand_posix_vars("$HOME/.hyfi/data")
assert Path(config.project_root).absolute() == Path.cwd().absolute()
assert (
Path(config.project_data_root).absolute() == Path.cwd().absolute() / "workspace"
)

# Test that the log_dir and cache_dir properties return the correct values
assert Path(config.log_dir).is_dir()
assert Path(config.cache_dir).is_dir()


if __name__ == "__main__":
test_path_config()

0 comments on commit ca87ba4

Please sign in to comment.