зеркало из
1
0
Форкнуть 0

fix asgi/wsgifunctionapps to extend bindingapi/settingapi (#209)

Co-authored-by: gavin-aguiar <80794152+gavin-aguiar@users.noreply.github.com>
Co-authored-by: hallvictoria <59299039+hallvictoria@users.noreply.github.com>
This commit is contained in:
wangbill 2024-07-17 09:56:42 -07:00 коммит произвёл GitHub
Родитель 7904799b83
Коммит ff2e803e5e
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
3 изменённых файлов: 26 добавлений и 7 удалений

Просмотреть файл

@ -3313,7 +3313,13 @@ class Blueprint(TriggerApi, BindingApi, SettingsApi):
pass pass
class ExternalHttpFunctionApp(FunctionRegister, TriggerApi, ABC): class ExternalHttpFunctionApp(
FunctionRegister,
TriggerApi,
SettingsApi,
BindingApi,
ABC
):
"""Interface to extend for building third party http function apps.""" """Interface to extend for building third party http function apps."""
@abc.abstractmethod @abc.abstractmethod

Просмотреть файл

@ -1,5 +1,6 @@
# Copyright (c) Microsoft Corporation. All rights reserved. # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. # Licensed under the MIT License.
from abc import ABC
import inspect import inspect
import json import json
import unittest import unittest
@ -11,10 +12,12 @@ from azure.functions.decorators.constants import HTTP_OUTPUT, HTTP_TRIGGER, \
TIMER_TRIGGER TIMER_TRIGGER
from azure.functions.decorators.core import DataType, AuthLevel, \ from azure.functions.decorators.core import DataType, AuthLevel, \
BindingDirection, SCRIPT_FILE_NAME BindingDirection, SCRIPT_FILE_NAME
from azure.functions.decorators.function_app import BindingApi, \ from azure.functions.decorators.function_app import (
FunctionBuilder, FunctionApp, Function, Blueprint, DecoratorApi, \ BindingApi, FunctionBuilder, FunctionApp, Function, Blueprint,
AsgiFunctionApp, WsgiFunctionApp, HttpFunctionsAuthLevelMixin, \ DecoratorApi, AsgiFunctionApp, SettingsApi, WsgiFunctionApp,
FunctionRegister, TriggerApi, ExternalHttpFunctionApp HttpFunctionsAuthLevelMixin, FunctionRegister, TriggerApi,
ExternalHttpFunctionApp
)
from azure.functions.decorators.http import HttpTrigger, HttpOutput, \ from azure.functions.decorators.http import HttpTrigger, HttpOutput, \
HttpMethod HttpMethod
from azure.functions.decorators.retry_policy import RetryPolicy from azure.functions.decorators.retry_policy import RetryPolicy
@ -322,6 +325,15 @@ class TestFunctionApp(unittest.TestCase):
self.assertIsInstance(add_http_app_mock.call_args[0][0], self.assertIsInstance(add_http_app_mock.call_args[0][0],
WsgiMiddleware) WsgiMiddleware)
def test_extends_required_classes(self):
self.assertTrue(issubclass(ExternalHttpFunctionApp, FunctionRegister))
self.assertTrue(issubclass(ExternalHttpFunctionApp, TriggerApi))
self.assertTrue(issubclass(ExternalHttpFunctionApp, SettingsApi))
self.assertTrue(issubclass(ExternalHttpFunctionApp, BindingApi))
self.assertTrue(issubclass(ExternalHttpFunctionApp, ABC))
self.assertTrue(issubclass(AsgiFunctionApp, ExternalHttpFunctionApp))
self.assertTrue(issubclass(WsgiFunctionApp, ExternalHttpFunctionApp))
def test_add_asgi_app(self): def test_add_asgi_app(self):
self._test_http_external_app(AsgiFunctionApp(app=object()), True) self._test_http_external_app(AsgiFunctionApp(app=object()), True)

Просмотреть файл

@ -181,9 +181,10 @@ class TestHTTP(unittest.TestCase):
def test_http_response_accepts_http_enums(self): def test_http_response_accepts_http_enums(self):
response = func.HttpResponse(status_code=404) response = func.HttpResponse(status_code=404)
self.assertEquals(response.status_code, 404) self.assertEqual(response.status_code, 404)
response = func.HttpResponse(status_code=HTTPStatus.ACCEPTED) response = func.HttpResponse(status_code=HTTPStatus.ACCEPTED)
self.assertEquals(response.status_code, 202) self.assertEqual(response.status_code, HTTPStatus.ACCEPTED.value)
def test_http_request_converter_decode(self): def test_http_request_converter_decode(self):
data = { data = {