File: test_misc.py

package info (click to toggle)
python-rfc3986 2.0.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 500 kB
  • sloc: python: 2,899; makefile: 18
file content (50 lines) | stat: -rw-r--r-- 1,496 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
from rfc3986.misc import merge_paths
from rfc3986.uri import URIReference


def test_merge_paths_with_base_path_without_base_authority():
    """Demonstrate merging with a base URI without an authority."""
    base = URIReference(
        scheme=None,
        authority=None,
        path="/foo/bar/bogus",
        query=None,
        fragment=None,
    )
    expected = "/foo/bar/relative"
    assert merge_paths(base, "relative") == expected


def test_merge_paths_with_base_authority_and_path():
    """Demonstrate merging with a base URI with an authority and path."""
    base = URIReference(
        scheme=None,
        authority="authority",
        path="/foo/bar/bogus",
        query=None,
        fragment=None,
    )
    expected = "/foo/bar/relative"
    assert merge_paths(base, "relative") == expected


def test_merge_paths_without_base_authority_or_path():
    """Demonstrate merging with a base URI without an authority or path."""
    base = URIReference(
        scheme=None, authority=None, path=None, query=None, fragment=None
    )
    expected = "/relative"
    assert merge_paths(base, "relative") == expected


def test_merge_paths_with_base_authority_without_path():
    """Demonstrate merging with a base URI without an authority or path."""
    base = URIReference(
        scheme=None,
        authority="authority",
        path=None,
        query=None,
        fragment=None,
    )
    expected = "/relative"
    assert merge_paths(base, "relative") == expected