aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_utils.py
blob: e0f0419321964bfce6b7e2ebf7433f99e3e490d5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from collections import namedtuple

from epy_reader.lib import resolve_path


def test_resolve_path():
    UnresolvedPath = namedtuple("UnresolvedPath", ["current_dir", "relative_path"])

    inputs = [
        UnresolvedPath("/aaa/bbb/book.html", "../ccc.png"),
        UnresolvedPath("/aaa/bbb/book.html", "../../ccc.png"),
        UnresolvedPath("aaa/bbb/book.html", "../../ccc.png"),
    ]

    expecteds = [
        "/aaa/ccc.png",
        "/ccc.png",
        "ccc.png",
    ]

    for input, expected in zip(inputs, expecteds):
        assert resolve_path(input.current_dir, input.relative_path) == expected