mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Test for JSON in query_string name, refs #621
Plus simplified implementation of test_request_blank_values
This commit is contained in:
parent
f5538e7161
commit
4f02c8d4d7
1 changed files with 14 additions and 12 deletions
|
|
@ -124,16 +124,18 @@ def test_request_properties(path, query_string, expected_full_path):
|
||||||
|
|
||||||
|
|
||||||
def test_request_blank_values():
|
def test_request_blank_values():
|
||||||
query_string = "a=b&foo=bar&foo=bar2&baz="
|
request = Request.fake("/?a=b&foo=bar&foo=bar2&baz=")
|
||||||
path_with_query_string = "/?" + query_string
|
|
||||||
scope = {
|
|
||||||
"http_version": "1.1",
|
|
||||||
"method": "POST",
|
|
||||||
"path": "/",
|
|
||||||
"raw_path": path_with_query_string.encode("latin-1"),
|
|
||||||
"query_string": query_string.encode("latin-1"),
|
|
||||||
"scheme": "http",
|
|
||||||
"type": "http",
|
|
||||||
}
|
|
||||||
request = Request(scope, None)
|
|
||||||
assert request.args._data == {"a": ["b"], "foo": ["bar", "bar2"], "baz": [""]}
|
assert request.args._data == {"a": ["b"], "foo": ["bar", "bar2"], "baz": [""]}
|
||||||
|
|
||||||
|
|
||||||
|
def test_json_in_query_string_name():
|
||||||
|
query_string = (
|
||||||
|
'?_through.["roadside_attraction_characteristics"%2C"characteristic_id"]=1'
|
||||||
|
)
|
||||||
|
request = Request.fake("/" + query_string)
|
||||||
|
assert (
|
||||||
|
request.args[
|
||||||
|
'_through.["roadside_attraction_characteristics","characteristic_id"]'
|
||||||
|
]
|
||||||
|
== "1"
|
||||||
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue