Skip to content

Commit

Permalink
Add test_rock_path.py
Browse files Browse the repository at this point in the history
  • Loading branch information
carlcsaposs-canonical committed Jul 18, 2023
1 parent e20cb40 commit f59bb91
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/unit/test_rock_path.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright 2023 Canonical Ltd.
# See LICENSE file for licensing details.
import functools
import pathlib

import rock

_Path = functools.partial(rock._Path, container_=None)


def test_path_joining():
assert _Path("/foo") == _Path("/foo")
assert _Path("/foo") / "bar" == _Path("/foo/bar")
assert "/etc" / _Path("foo") / "bar" == _Path("/etc/foo/bar")
assert "/etc" / _Path("foo") / "bar" / "baz" == _Path("/etc/foo/bar/baz")
assert _Path("/etc", "foo", "bar", "baz") == _Path("/etc/foo/bar/baz")
assert _Path("foo") == _Path("foo")
assert "etc" / _Path("foo") / "bar" / "baz" == _Path("etc/foo/bar/baz")


def test_relative_to_container():
assert _Path("/foo").relative_to_container == pathlib.PurePath("/foo")
assert _Path("/foo/bar").relative_to_container == pathlib.PurePath("/foo/bar")
assert _Path("baz").relative_to_container == pathlib.PurePath("baz")

0 comments on commit f59bb91

Please sign in to comment.