Skip to content

Commit

Permalink
style (testing): fix errors in gates
Browse files Browse the repository at this point in the history
  • Loading branch information
aarcex3 committed Oct 6, 2024
1 parent 5ce771e commit af1b505
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion falcon/testing/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -977,7 +977,7 @@ def create_scope(
"""

http_version = _fixup_http_version(http_version)

raw_path = path.split('?')[0]
path = uri.decode(path, unquote_plus=False)

# NOTE(kgriffs): Handles both None and ''
Expand All @@ -995,6 +995,7 @@ def create_scope(
'http_version': http_version,
'method': method.upper(),
'path': path,
'raw_path': raw_path.encode(),
'query_string': query_string_bytes,
}

Expand Down
11 changes: 11 additions & 0 deletions tests/asgi/test_testing_asgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,14 @@ def test_immediate_disconnect():

with pytest.raises(ConnectionError):
client.simulate_get('/', asgi_disconnect_ttl=0)


def test_create_scope_preserve_raw_path():
path_no_queries = '/cache/http%3A%2F%2Ffalconframework.org/status'
scope = testing.create_scope(path=path_no_queries)
assert scope['raw_path'] == path_no_queries.encode()
path_with_queries = (
'/cache/http%3A%2F%2Ffalconframework.org/status?param1=value1&param2=value2'
)
scope = testing.create_scope(path=path_with_queries)
assert scope['raw_path'] != path_with_queries.encode()

0 comments on commit af1b505

Please sign in to comment.