-
Notifications
You must be signed in to change notification settings - Fork 108
blueprint change: worker indexing functionregister #1065
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
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
92278dc
blueprint change: worker indexing functionregister
8357066
fix flakey8
d813662
temp update to 3b2
YunchuWang 47c2800
update unit tests
6c59cc0
fix functionregister err msg
4593265
Merge branch 'dev' into wangbill/blueprint
vrdmr 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
31 changes: 31 additions & 0 deletions
31
tests/endtoend/blueprint_functions/functions_in_blueprint_only/blueprint.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 @@ | ||
import logging | ||
|
||
import azure.functions as func | ||
|
||
bp = func.Blueprint() | ||
|
||
|
||
@bp.route(route="default_template") | ||
def default_template(req: func.HttpRequest) -> func.HttpResponse: | ||
logging.info('Python HTTP trigger function processed a request.') | ||
|
||
name = req.params.get('name') | ||
if not name: | ||
try: | ||
req_body = req.get_json() | ||
except ValueError: | ||
pass | ||
else: | ||
name = req_body.get('name') | ||
|
||
if name: | ||
return func.HttpResponse( | ||
f"Hello, {name}. This HTTP triggered function " | ||
f"executed successfully.") | ||
else: | ||
return func.HttpResponse( | ||
"This HTTP triggered function executed successfully. " | ||
"Pass a name in the query string or in the request body for a" | ||
" personalized response.", | ||
status_code=200 | ||
) |
6 changes: 6 additions & 0 deletions
6
tests/endtoend/blueprint_functions/functions_in_blueprint_only/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,6 @@ | ||
import azure.functions as func | ||
from blueprint import bp | ||
|
||
app = func.FunctionApp() | ||
|
||
app.register_functions(bp) |
31 changes: 31 additions & 0 deletions
31
tests/endtoend/blueprint_functions/functions_in_both_blueprint_functionapp/blueprint.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 @@ | ||
import logging | ||
|
||
import azure.functions as func | ||
|
||
bp = func.Blueprint() | ||
|
||
|
||
@bp.route(route="default_template") | ||
def default_template(req: func.HttpRequest) -> func.HttpResponse: | ||
logging.info('Python HTTP trigger function processed a request.') | ||
|
||
name = req.params.get('name') | ||
if not name: | ||
try: | ||
req_body = req.get_json() | ||
except ValueError: | ||
pass | ||
else: | ||
name = req_body.get('name') | ||
|
||
if name: | ||
return func.HttpResponse( | ||
f"Hello, {name}. This HTTP triggered function " | ||
f"executed successfully.") | ||
else: | ||
return func.HttpResponse( | ||
"This HTTP triggered function executed successfully. " | ||
"Pass a name in the query string or in the request body for a" | ||
" personalized response.", | ||
status_code=200 | ||
) |
13 changes: 13 additions & 0 deletions
13
tests/endtoend/blueprint_functions/functions_in_both_blueprint_functionapp/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,13 @@ | ||
import azure.functions as func | ||
|
||
from blueprint import bp | ||
|
||
app = func.FunctionApp() | ||
|
||
app.register_blueprint(bp) | ||
|
||
|
||
@app.route(route="return_http") | ||
def return_http(req: func.HttpRequest): | ||
return func.HttpResponse('<h1>Hello World™</h1>', | ||
mimetype='text/html') |
12 changes: 12 additions & 0 deletions
12
tests/endtoend/blueprint_functions/multiple_function_registers/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,12 @@ | ||
import azure.functions as func | ||
|
||
app = func.FunctionApp() | ||
|
||
|
||
@app.route(route="return_http") | ||
def return_http(req: func.HttpRequest): | ||
return func.HttpResponse('<h1>Hello World™</h1>', | ||
mimetype='text/html') | ||
|
||
|
||
asgi_app = func.AsgiFunctionApp() |
31 changes: 31 additions & 0 deletions
31
tests/endtoend/blueprint_functions/only_blueprint/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 @@ | ||
import logging | ||
|
||
import azure.functions as func | ||
|
||
bp = func.Blueprint() | ||
|
||
|
||
@bp.route(route="default_template") | ||
def default_template(req: func.HttpRequest) -> func.HttpResponse: | ||
logging.info('Python HTTP trigger function processed a request.') | ||
|
||
name = req.params.get('name') | ||
if not name: | ||
try: | ||
req_body = req.get_json() | ||
except ValueError: | ||
pass | ||
else: | ||
name = req_body.get('name') | ||
|
||
if name: | ||
return func.HttpResponse( | ||
f"Hello, {name}. This HTTP triggered function " | ||
f"executed successfully.") | ||
else: | ||
return func.HttpResponse( | ||
"This HTTP triggered function executed successfully. " | ||
"Pass a name in the query string or in the request body for a" | ||
" personalized response.", | ||
status_code=200 | ||
) |
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,59 @@ | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. | ||
|
||
from azure_functions_worker import testutils | ||
|
||
|
||
class TestFunctionInBluePrintOnly(testutils.WebHostTestCase): | ||
@classmethod | ||
def get_script_dir(cls): | ||
return testutils.E2E_TESTS_FOLDER / 'blueprint_functions' / \ | ||
'functions_in_blueprint_only' | ||
|
||
@testutils.retryable_test(3, 5) | ||
def test_function_in_blueprint_only(self): | ||
r = self.webhost.request('GET', 'default_template') | ||
self.assertTrue(r.ok) | ||
|
||
|
||
class TestFunctionsInBothBlueprintAndFuncApp(testutils.WebHostTestCase): | ||
@classmethod | ||
def get_script_dir(cls): | ||
return testutils.E2E_TESTS_FOLDER / 'blueprint_functions' / \ | ||
'functions_in_both_blueprint_functionapp' | ||
|
||
@testutils.retryable_test(3, 5) | ||
def test_functions_in_both_blueprint_functionapp(self): | ||
r = self.webhost.request('GET', 'default_template') | ||
self.assertTrue(r.ok) | ||
|
||
r = self.webhost.request('GET', 'return_http') | ||
self.assertTrue(r.ok) | ||
|
||
|
||
class TestMultipleFunctionRegisters(testutils.WebHostTestCase): | ||
@classmethod | ||
def get_script_dir(cls): | ||
return testutils.E2E_TESTS_FOLDER / 'blueprint_functions' / \ | ||
'multiple_function_registers' | ||
|
||
@testutils.retryable_test(3, 5) | ||
def test_function_in_blueprint_only(self): | ||
r = self.webhost.request('GET', 'return_http') | ||
self.assertEqual(r.status_code, 404) | ||
|
||
YunchuWang marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
class TestOnlyBlueprint(testutils.WebHostTestCase): | ||
@classmethod | ||
def get_script_dir(cls): | ||
return testutils.E2E_TESTS_FOLDER / 'blueprint_functions' / \ | ||
'only_blueprint' | ||
|
||
@testutils.retryable_test(3, 5) | ||
def test_only_blueprint(self): | ||
"""Test if the default template of Http trigger in Python | ||
Function app | ||
will return OK | ||
""" | ||
r = self.webhost.request('GET', 'default_template') | ||
self.assertEqual(r.status_code, 404) |
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
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.