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:
Родитель
7904799b83
Коммит
ff2e803e5e
|
@ -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 = {
|
||||
|
|
Загрузка…
Ссылка в новой задаче