Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: asgi/wsgifunctionapps to extend bindingapi/settingapi #209

Merged
merged 5 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion azure/functions/decorators/function_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 16 additions & 4 deletions tests/decorators/test_function_app.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -11,10 +12,12 @@
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
Expand Down Expand Up @@ -322,6 +325,15 @@ def test_add_wsgi(self, add_http_app_mock):
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)

Expand Down
5 changes: 3 additions & 2 deletions tests/test_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,10 @@ def test_http_response_does_not_have_explicit_output(self):

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 = {
Expand Down
Loading