-
Notifications
You must be signed in to change notification settings - Fork 556
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
jsonld - Improve handling of URNs in norm_url (#2892)
* jsonld - Improve handling of URNs in norm_url * Fix import package * Fix formatting with black
- Loading branch information
Showing
2 changed files
with
43 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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" |