Skip to content

Commit 5ae764f

Browse files
committed
refactor
1 parent 1c28ed9 commit 5ae764f

File tree

2 files changed

+13
-16
lines changed

2 files changed

+13
-16
lines changed

azure/functions/decorators/function_app.py

+13-13
Original file line numberDiff line numberDiff line change
@@ -1694,26 +1694,27 @@ def __init__(self, app,
16941694
"""Constructor of :class:`AsgiFunctionApp` object.
16951695
16961696
:param app: asgi app object.
1697+
:param http_auth_level: Determines what keys, if any, need to be
1698+
present
1699+
on the request in order to invoke the function.
16971700
"""
16981701
super().__init__(auth_level=http_auth_level)
1699-
self._add_http_app(AsgiMiddleware(app), 'asgi')
1702+
self._add_http_app(AsgiMiddleware(app))
17001703

1701-
def _add_http_app(self,
1702-
http_middleware: AsgiMiddleware,
1703-
http_type: str) -> None:
1704+
def _add_http_app(self, asgi_middleware: AsgiMiddleware) -> None:
17041705
"""Add an Asgi app integrated http function.
17051706
1706-
:param http_middleware: :class:`AsgiMiddleware` instance.
1707+
:param asgi_middleware: :class:`AsgiMiddleware` instance.
17071708
17081709
:return: None
17091710
"""
17101711

1711-
@self.http_type(http_type=http_type)
1712+
@self.http_type(http_type='asgi')
17121713
@self.route(methods=(method for method in HttpMethod),
17131714
auth_level=self.auth_level,
17141715
route="/{*route}")
17151716
async def http_app_func(req: HttpRequest, context: Context):
1716-
return await http_middleware.handle_async(req, context)
1717+
return await asgi_middleware.handle_async(req, context)
17171718

17181719

17191720
class WsgiFunctionApp(ExternalHttpFunctionApp):
@@ -1724,21 +1725,20 @@ def __init__(self, app,
17241725
:param app: wsgi app object.
17251726
"""
17261727
super().__init__(auth_level=http_auth_level)
1727-
self._add_http_app(WsgiMiddleware(app), 'wsgi')
1728+
self._add_http_app(WsgiMiddleware(app))
17281729

17291730
def _add_http_app(self,
1730-
http_middleware: WsgiMiddleware,
1731-
http_type: str) -> None:
1731+
wsgi_middleware: WsgiMiddleware) -> None:
17321732
"""Add a Wsgi app integrated http function.
17331733
1734-
:param http_middleware: :class:`WsgiMiddleware` instance.
1734+
:param wsgi_middleware: :class:`WsgiMiddleware` instance.
17351735
17361736
:return: None
17371737
"""
17381738

1739-
@self.http_type(http_type=http_type)
1739+
@self.http_type(http_type='wsgi')
17401740
@self.route(methods=(method for method in HttpMethod),
17411741
auth_level=self.auth_level,
17421742
route="/{*route}")
17431743
def http_app_func(req: HttpRequest, context: Context):
1744-
return http_middleware.handle(req, context)
1744+
return wsgi_middleware.handle(req, context)

tests/decorators/test_function_app.py

-3
Original file line numberDiff line numberDiff line change
@@ -303,8 +303,6 @@ def test_add_asgi(self, add_http_app_mock):
303303
self.assertIsInstance(add_http_app_mock.call_args[0][0],
304304
AsgiMiddleware)
305305

306-
self.assertEqual(add_http_app_mock.call_args[0][1], 'asgi')
307-
308306
@mock.patch('azure.functions.decorators.function_app.WsgiFunctionApp'
309307
'._add_http_app')
310308
def test_add_wsgi(self, add_http_app_mock):
@@ -314,7 +312,6 @@ def test_add_wsgi(self, add_http_app_mock):
314312
add_http_app_mock.assert_called_once()
315313
self.assertIsInstance(add_http_app_mock.call_args[0][0],
316314
WsgiMiddleware)
317-
self.assertEqual(add_http_app_mock.call_args[0][1], 'wsgi')
318315

319316
def test_add_asgi_app(self):
320317
self._test_http_external_app(AsgiFunctionApp(app=object()), True)

0 commit comments

Comments
 (0)