зеркало из
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
class ExternalHttpFunctionApp(FunctionRegister, TriggerApi, ABC):
class ExternalHttpFunctionApp(
FunctionRegister,
TriggerApi,
SettingsApi,
BindingApi,
ABC
):
"""Interface to extend for building third party http function apps."""
@abc.abstractmethod

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

@ -1,5 +1,6 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
from abc import ABC
import inspect
import json
import unittest
@ -11,10 +12,12 @@ from azure.functions.decorators.constants import HTTP_OUTPUT, HTTP_TRIGGER, \
TIMER_TRIGGER
from azure.functions.decorators.core import DataType, AuthLevel, \
BindingDirection, SCRIPT_FILE_NAME
from azure.functions.decorators.function_app import BindingApi, \
FunctionBuilder, FunctionApp, Function, Blueprint, DecoratorApi, \
AsgiFunctionApp, WsgiFunctionApp, HttpFunctionsAuthLevelMixin, \
FunctionRegister, TriggerApi, ExternalHttpFunctionApp
from azure.functions.decorators.function_app import (
BindingApi, FunctionBuilder, FunctionApp, Function, Blueprint,
DecoratorApi, AsgiFunctionApp, SettingsApi, WsgiFunctionApp,
HttpFunctionsAuthLevelMixin, FunctionRegister, TriggerApi,
ExternalHttpFunctionApp
)
from azure.functions.decorators.http import HttpTrigger, HttpOutput, \
HttpMethod
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],
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):
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):
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)
self.assertEquals(response.status_code, 202)
self.assertEqual(response.status_code, HTTPStatus.ACCEPTED.value)
def test_http_request_converter_decode(self):
data = {