source: uri/tests/test_misc.py@ 1351

Last change on this file since 1351 was 230, checked in by wouter, 3 years ago

#91 clone https://pypi.org/project/rfc3986/

File size: 1.5 KB
Line 
1# -*- coding: utf-8 -*-
2from rfc3986.uri import URIReference
3from rfc3986.misc import merge_paths
4
5
6def test_merge_paths_with_base_path_without_base_authority():
7 """Demonstrate merging with a base URI without an authority."""
8 base = URIReference(
9 scheme=None,
10 authority=None,
11 path="/foo/bar/bogus",
12 query=None,
13 fragment=None,
14 )
15 expected = "/foo/bar/relative"
16 assert merge_paths(base, "relative") == expected
17
18
19def test_merge_paths_with_base_authority_and_path():
20 """Demonstrate merging with a base URI with an authority and path."""
21 base = URIReference(
22 scheme=None,
23 authority="authority",
24 path="/foo/bar/bogus",
25 query=None,
26 fragment=None,
27 )
28 expected = "/foo/bar/relative"
29 assert merge_paths(base, "relative") == expected
30
31
32def test_merge_paths_without_base_authority_or_path():
33 """Demonstrate merging with a base URI without an authority or path."""
34 base = URIReference(
35 scheme=None, authority=None, path=None, query=None, fragment=None
36 )
37 expected = "/relative"
38 assert merge_paths(base, "relative") == expected
39
40
41def test_merge_paths_with_base_authority_without_path():
42 """Demonstrate merging with a base URI without an authority or path."""
43 base = URIReference(
44 scheme=None,
45 authority="authority",
46 path=None,
47 query=None,
48 fragment=None,
49 )
50 expected = "/relative"
51 assert merge_paths(base, "relative") == expected
Note: See TracBrowser for help on using the repository browser.