-
Notifications
You must be signed in to change notification settings - Fork 107
Enabled implicit output for generic bindings #1391
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
Merged
hallvictoria
merged 26 commits into
dev
from
hallvictoria/enable_generic_implicit_output
Mar 6, 2024
Merged
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
409ad9a
enabled implicit output for generic bindings
hallvictoria c2321a5
should only fail durable tests?
hallvictoria 3a7bcc5
special case for table
hallvictoria 9132411
extra test for table
hallvictoria 5325c81
Merge branch 'dev' into hallvictoria/enable_generic_implicit_output
YunchuWang d20dac5
special case for logic apps
hallvictoria f3d3743
Merge branch 'hallvictoria/enable_generic_implicit_output' of https:/…
hallvictoria 74ebb56
Merge branch 'dev' of https://github.com/Azure/azure-functions-python…
hallvictoria 823375f
special case for durable
hallvictoria e1e9c1b
fixing failing eventhub batch test
hallvictoria b93b597
added output binding
hallvictoria 8e4996c
flake
hallvictoria b864c31
eventhub output binding
hallvictoria 05f89d4
flake
hallvictoria d3aa340
changed param name
hallvictoria 0d8d3d9
add_function prio explicit return type
hallvictoria 90d2651
Merge branch 'dev' into hallvictoria/enable_generic_implicit_output
hallvictoria d8e8ac1
added tests
hallvictoria 0f5b223
Merge branch 'hallvictoria/enable_generic_implicit_output' of https:/…
hallvictoria 751943f
added V2 test
hallvictoria a0541cd
remove if cond for durable client
hallvictoria 76bfe95
lint
hallvictoria 7b96bc3
Revert "remove if cond for durable client"
hallvictoria 05b0659
Merge branch 'dev' into hallvictoria/enable_generic_implicit_output
hallvictoria cd9047c
Merge branch 'dev' into hallvictoria/enable_generic_implicit_output
hallvictoria 466ee73
Merge branch 'dev' into hallvictoria/enable_generic_implicit_output
hallvictoria File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
tests/endtoend/generic_functions/generic_functions_stein/function_app.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. | ||
import azure.functions as func | ||
|
||
app = func.FunctionApp(http_auth_level=func.AuthLevel.ANONYMOUS) | ||
|
||
|
||
@app.function_name(name="return_processed_last") | ||
@app.generic_trigger(arg_name="req", type="httpTrigger", | ||
route="return_processed_last") | ||
@app.generic_output_binding(arg_name="$return", type="http") | ||
@app.generic_input_binding( | ||
arg_name="testEntity", | ||
type="table", | ||
connection="AzureWebJobsStorage", | ||
table_name="EventHubBatchTest") | ||
def return_processed_last(req: func.HttpRequest, testEntity): | ||
return func.HttpResponse(status_code=200) | ||
|
||
|
||
@app.function_name(name="return_not_processed_last") | ||
@app.generic_trigger(arg_name="req", type="httpTrigger", | ||
route="return_not_processed_last") | ||
@app.generic_output_binding(arg_name="$return", type="http") | ||
@app.generic_input_binding( | ||
arg_name="testEntities", | ||
type="table", | ||
connection="AzureWebJobsStorage", | ||
table_name="EventHubBatchTest") | ||
def return_not_processed_last(req: func.HttpRequest, testEntities): | ||
return func.HttpResponse(status_code=200) |
13 changes: 13 additions & 0 deletions
13
tests/endtoend/generic_functions/return_not_processed_last/__init__.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. | ||
import azure.functions as func | ||
|
||
|
||
# There are 3 bindings defined in function.json: | ||
# 1. req: HTTP trigger | ||
# 2. testEntities: table input (generic) | ||
# 3. $return: HTTP response | ||
# The bindings will be processed by the worker in this order: | ||
# req -> $return -> testEntities | ||
def main(req: func.HttpRequest, testEntities): | ||
return func.HttpResponse(status_code=200) |
26 changes: 26 additions & 0 deletions
26
tests/endtoend/generic_functions/return_not_processed_last/function.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"scriptFile": "__init__.py", | ||
"bindings": [ | ||
{ | ||
"type": "httpTrigger", | ||
"direction": "in", | ||
"authLevel": "anonymous", | ||
"methods": [ | ||
"get" | ||
], | ||
"name": "req" | ||
}, | ||
{ | ||
"direction": "in", | ||
"type": "table", | ||
"name": "testEntities", | ||
"tableName": "EventHubBatchTest", | ||
"connection": "AzureWebJobsStorage" | ||
}, | ||
{ | ||
"type": "http", | ||
"direction": "out", | ||
"name": "$return" | ||
} | ||
] | ||
} |
13 changes: 13 additions & 0 deletions
13
tests/endtoend/generic_functions/return_processed_last/__init__.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. | ||
import azure.functions as func | ||
|
||
|
||
# There are 3 bindings defined in function.json: | ||
# 1. req: HTTP trigger | ||
# 2. testEntity: table input (generic) | ||
# 3. $return: HTTP response | ||
# The bindings will be processed by the worker in this order: | ||
# req -> testEntity -> $return | ||
def main(req: func.HttpRequest, testEntity): | ||
return func.HttpResponse(status_code=200) |
26 changes: 26 additions & 0 deletions
26
tests/endtoend/generic_functions/return_processed_last/function.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"scriptFile": "__init__.py", | ||
"bindings": [ | ||
{ | ||
"type": "httpTrigger", | ||
"direction": "in", | ||
"authLevel": "anonymous", | ||
"methods": [ | ||
"get" | ||
], | ||
"name": "req" | ||
}, | ||
{ | ||
"direction": "in", | ||
"type": "table", | ||
"name": "testEntity", | ||
"tableName": "EventHubBatchTest", | ||
"connection": "AzureWebJobsStorage" | ||
}, | ||
{ | ||
"type": "http", | ||
"direction": "out", | ||
"name": "$return" | ||
} | ||
] | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. | ||
from unittest import skipIf | ||
|
||
from azure_functions_worker.utils.common import is_envvar_true | ||
from tests.utils import testutils | ||
from tests.utils.constants import DEDICATED_DOCKER_TEST, CONSUMPTION_DOCKER_TEST | ||
|
||
|
||
@skipIf(is_envvar_true(DEDICATED_DOCKER_TEST) | ||
or is_envvar_true(CONSUMPTION_DOCKER_TEST), | ||
"Table functions which are used in the bindings in these tests" | ||
" has a bug with the table extension 1.0.0. " | ||
"https://github.com/Azure/azure-sdk-for-net/issues/33902.") | ||
class TestGenericFunctions(testutils.WebHostTestCase): | ||
"""Test Generic Functions with implicit output enabled | ||
|
||
With implicit output enabled for generic types, these tests cover | ||
scenarios where a function has both explicit and implicit output | ||
set to true. We prioritize explicit output. These tests check | ||
that no matter the ordering, the return type is still correctly set. | ||
""" | ||
|
||
@classmethod | ||
def get_script_dir(cls): | ||
return testutils.E2E_TESTS_FOLDER / 'generic_functions' | ||
|
||
def test_return_processed_last(self): | ||
# Tests the case where implicit and explicit return are true | ||
# in the same function and $return is processed before | ||
# the generic binding is | ||
|
||
r = self.webhost.request('GET', 'return_processed_last') | ||
self.assertEqual(r.status_code, 200) | ||
|
||
def test_return_not_processed_last(self): | ||
# Tests the case where implicit and explicit return are true | ||
# in the same function and the generic binding is processed | ||
# before $return | ||
|
||
r = self.webhost.request('GET', 'return_not_processed_last') | ||
self.assertEqual(r.status_code, 200) | ||
|
||
|
||
@skipIf(is_envvar_true(DEDICATED_DOCKER_TEST) | ||
or is_envvar_true(CONSUMPTION_DOCKER_TEST), | ||
"Table functions has a bug with the table extension 1.0.0." | ||
"https://github.com/Azure/azure-sdk-for-net/issues/33902.") | ||
class TestGenericFunctionsStein(TestGenericFunctions): | ||
|
||
@classmethod | ||
def get_script_dir(cls): | ||
return testutils.E2E_TESTS_FOLDER / 'generic_functions' / \ | ||
'generic_functions_stein' |
12 changes: 12 additions & 0 deletions
12
tests/unittests/generic_functions/foobar_implicit_output_exemption/function.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"scriptFile": "main.py", | ||
"bindings": [ | ||
{ | ||
"type": "durableClient", | ||
"name": "input", | ||
"direction": "in", | ||
"dataType": "string" | ||
} | ||
] | ||
} | ||
|
7 changes: 7 additions & 0 deletions
7
tests/unittests/generic_functions/foobar_implicit_output_exemption/main.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. | ||
# Input as string, without annotation | ||
|
||
|
||
def main(input: str): | ||
return input |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.