tests: add utils.py tests
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
cătălin 2022-08-28 22:24:16 +02:00
commit d9eb99b72e
Signed by: catalin
GPG key ID: 0178DF42F43E5FD2
9 changed files with 71 additions and 28 deletions

33
tests/test_utils.py Normal file
View file

@ -0,0 +1,33 @@
import os
from pathlib import Path
from halig.utils import resolve_path
def test_resolve_absolute_path():
path = Path("/foo/bar/baz")
assert resolve_path(path) == path
def test_resolve_user_path():
path = Path("~/foo/bar/baz")
assert resolve_path(path) == path.expanduser()
def test_resolve_path_with_envvars():
os.environ["FOO"] = "foo"
os.environ["BAR"] = "bar"
path = Path("/${FOO}/${BAR}")
assert resolve_path(path) == Path("/foo/bar")
def test_resolve_relative_path():
path = Path("foo/bar/baz")
assert resolve_path(path) == path.resolve()
def test_resolve_path_all():
os.environ["FOO"] = "foo"
os.environ["BAR"] = "bar"
path = Path("foo/bar/$FOO/../$BAR")
assert resolve_path(path) == Path(os.path.expandvars(path)).resolve().expanduser()