Skip to content

Commit

Permalink
test (test_recipes): update test for asgi scope
Browse files Browse the repository at this point in the history
  • Loading branch information
aarcex3 committed Oct 6, 2024
1 parent 44ecff3 commit b153614
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
16 changes: 11 additions & 5 deletions tests/asgi/test_testing_asgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,17 @@ def test_immediate_disconnect():
client.simulate_get('/', asgi_disconnect_ttl=0)


@pytest.mark.parametrize('path, expected', [
('/cache/http%3A%2F%2Ffalconframework.org/status', True),
('/cache/http%3A%2F%2Ffalconframework.org/status?param1=value1&param2=value2', False)
])
def test_create_scope_preserve_raw_path(path: str, expected: bool):
@pytest.mark.parametrize(
'path, expected',
[
('/cache/http%3A%2F%2Ffalconframework.org/status', True),
(
'/cache/http%3A%2F%2Ffalconframework.org/status?param1=value1&param2=value2',
False,
),
],
)
def test_create_scope_preserve_raw_path(path, expected):
scope = testing.create_scope(path=path)
if expected:
assert scope['raw_path'] == path.encode()
Expand Down
4 changes: 4 additions & 0 deletions tests/test_recipes.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,16 @@ def test_raw_path(self, asgi, app_kind, util):
result1 = falcon.testing.simulate_get(
recipe.app, url1, extras=self.path_extras(asgi, url1)
)
scope1 = falcon.testing.create_scope(url1)
assert result1.status_code == 200
assert result1.json == {'url': 'http://falconframework.org'}
assert scope1['raw_path'] == url1.encode()

url2 = '/cache/http%3A%2F%2Ffalconframework.org/status'
result2 = falcon.testing.simulate_get(
recipe.app, url2, extras=self.path_extras(asgi, url2)
)
scope2 = falcon.testing.create_scope(url2)
assert result2.status_code == 200
assert result2.json == {'cached': True}
assert scope2['raw_path'] == url2.encode()

0 comments on commit b153614

Please sign in to comment.