-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
107 additions
and
15 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
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 |
---|---|---|
|
@@ -90,6 +90,64 @@ def test_uri_parse_http_with_query_string(): | |
testing.assert_equal(uri._original_path, "/job") | ||
testing.assert_equal(uri.request_uri, "/job?title=engineer") | ||
testing.assert_equal(uri.query_string, "title=engineer") | ||
testing.assert_equal(uri.queries["title"], "engineer") | ||
|
||
|
||
def test_uri_parse_multiple_query_parameters(): | ||
var uri = URI.parse("http://example.com/search?q=python&page=1&limit=20") | ||
testing.assert_equal(uri.scheme, "http") | ||
testing.assert_equal(uri.host, "example.com") | ||
testing.assert_equal(uri.path, "/search") | ||
testing.assert_equal(uri.query_string, "q=python&page=1&limit=20") | ||
testing.assert_equal(uri.queries["q"], "python") | ||
testing.assert_equal(uri.queries["page"], "1") | ||
testing.assert_equal(uri.queries["limit"], "20") | ||
testing.assert_equal(uri.request_uri, "/search?q=python&page=1&limit=20") | ||
|
||
|
||
def test_uri_parse_query_with_special_characters(): | ||
var uri = URI.parse("https://example.com/path?name=John+Doe&email=john%40example.com") | ||
testing.assert_equal(uri.scheme, "https") | ||
testing.assert_equal(uri.host, "example.com") | ||
testing.assert_equal(uri.path, "/path") | ||
testing.assert_equal(uri.query_string, "name=John+Doe&email=john%40example.com") | ||
# testing.assert_equal(uri.queries["name"], "John Doe") - fails, contains John+Doe | ||
# testing.assert_equal(uri.queries["email"], "[email protected]") - fails, contains john%40example.com | ||
|
||
|
||
def test_uri_parse_empty_query_values(): | ||
var uri = URI.parse("http://example.com/api?key=&token=&empty") | ||
testing.assert_equal(uri.query_string, "key=&token=&empty") | ||
testing.assert_equal(uri.queries["key"], "") | ||
testing.assert_equal(uri.queries["token"], "") | ||
testing.assert_equal(uri.queries["empty"], "") | ||
|
||
|
||
def test_uri_parse_complex_query(): | ||
var uri = URI.parse("https://example.com/search?q=test&filter[category]=books&filter[price]=10-20&sort=desc&page=1") | ||
testing.assert_equal(uri.scheme, "https") | ||
testing.assert_equal(uri.host, "example.com") | ||
testing.assert_equal(uri.path, "/search") | ||
testing.assert_equal(uri.query_string, "q=test&filter[category]=books&filter[price]=10-20&sort=desc&page=1") | ||
testing.assert_equal(uri.queries["q"], "test") | ||
testing.assert_equal(uri.queries["filter[category]"], "books") | ||
testing.assert_equal(uri.queries["filter[price]"], "10-20") | ||
testing.assert_equal(uri.queries["sort"], "desc") | ||
testing.assert_equal(uri.queries["page"], "1") | ||
|
||
|
||
def test_uri_parse_query_with_unicode(): | ||
var uri = URI.parse("http://example.com/search?q=%E2%82%AC&lang=%F0%9F%87%A9%F0%9F%87%AA") | ||
testing.assert_equal(uri.query_string, "q=%E2%82%AC&lang=%F0%9F%87%A9%F0%9F%87%AA") | ||
# testing.assert_equal(uri.queries["q"], "€") - fails, contains %E2%82%AC | ||
# testing.assert_equal(uri.queries["lang"], "🇩🇪") - fails, contains %F0%9F%87%A9%F0%9F%87%AA | ||
|
||
|
||
# def test_uri_parse_query_with_fragments(): | ||
# var uri = URI.parse("http://example.com/page?id=123#section1") | ||
# testing.assert_equal(uri.query_string, "id=123") | ||
# testing.assert_equal(uri.queries["id"], "123") | ||
# testing.assert_equal(...) - how do we treat fragments? | ||
|
||
|
||
def test_uri_parse_no_scheme(): | ||
|