Skip to content

Commit 08d4b2f

Browse files
committed
add tests
1 parent 2106999 commit 08d4b2f

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

tests/test_http_asgi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,4 +301,4 @@ def test_calling_shutdown_without_startup_errors(self):
301301
with pytest.raises(RuntimeError):
302302
asyncio.get_event_loop().run_until_complete(
303303
middleware.notify_shutdown()
304-
)
304+
)

tests/test_http_wsgi.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import threading
44
import unittest
55
from io import StringIO, BytesIO
6+
from unittest.mock import MagicMock
67

78
import pytest
89

@@ -14,7 +15,7 @@
1415
WsgiResponse,
1516
WsgiMiddleware
1617
)
17-
18+
from azure.functions._http_asgi import AsgiRequest
1819

1920
class WsgiException(Exception):
2021
def __init__(self, message=''):
@@ -211,6 +212,18 @@ def test_middleware_wrapper(self):
211212
self.assertEqual(func_response.status_code, 200)
212213
self.assertEqual(func_response.get_body(), b'sample string')
213214

215+
def test_path_encoding_utf8(self):
216+
url = 'http://example.com/Pippi%20L%C3%A5ngstrump'
217+
request = AsgiRequest(self._generate_func_request(url=url))
218+
219+
self.assertEqual(request.path_info, '/Pippi Långstrump')
220+
221+
def test_path_encoding_latin1(self):
222+
url = 'http://example.com/Pippi%20L%C3%A5ngstrump'
223+
request = WsgiRequest(self._generate_func_request(url=url))
224+
225+
self.assertEqual(request.path_info, '/Pippi LÃ¥ngstrump')
226+
214227
def _generate_func_request(
215228
self,
216229
method="POST",

0 commit comments

Comments
 (0)