File: test_norm_urn.py

package info (click to toggle)
rdflib 7.1.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 77,580 kB
  • sloc: python: 58,671; sh: 153; makefile: 88; ruby: 74; xml: 45
file content (21 lines) | stat: -rw-r--r-- 988 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
from rdflib.plugins.shared.jsonld.util import norm_url


def test_norm_urn():
    assert norm_url("urn:ns:test", "/one") == "urn:ns:test/one"
    assert norm_url("urn:ns:test/path/", "two") == "urn:ns:test/path/two"
    assert norm_url("urn:ns:test/path", "two") == "urn:ns:test/two"
    assert norm_url("urn:ns:test", "three") == "urn:ns:test/three"
    assert norm_url("urn:ns:test/path#", "four") == "urn:ns:test/four"
    assert norm_url("urn:ns:test/path1/path2/", "../path3") == "urn:ns:test/path1/path3"
    assert norm_url("urn:ns:test/path1/path2/", "/path3") == "urn:ns:test/path3"
    assert (
        norm_url("urn:ns:test/path1/path2/", "http://example.com")
        == "http://example.com"
    )
    assert (
        norm_url("urn:ns:test/path1/path2/", "urn:another:test/path")
        == "urn:another:test/path"
    )
    assert norm_url("urn:ns:test/path", "#four") == "urn:ns:test/path#four"
    assert norm_url("urn:ns:test/path/", "#four") == "urn:ns:test/path/#four"