-
Notifications
You must be signed in to change notification settings - Fork 107
Add SQL Bindings end to end test #1026
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
15 commits
Select commit
Hold shift + click to select a range
8b21929
add sql bindings e2e test
lucyzhang929 aaf2b2e
update test
lucyzhang929 bd475fa
add sql bindings e2e test
lucyzhang929 2b445f5
update test
lucyzhang929 b66358d
Merge branch 'dev' into luczhan/addsqlbindinge2etests
gavin-aguiar 23827c5
Merge branch 'luczhan/addsqlbindinge2etests' of https://github.com/Az…
lucyzhang929 3e98927
fix sql binding test
lucyzhang929 13ce795
add python310 sql connection string
lucyzhang929 0bc78c7
Merge branch 'dev' into luczhan/addsqlbindinge2etests
gavin-aguiar b7142ed
fix unit tests
lucyzhang929 a89fffc
Merge branch 'luczhan/addsqlbindinge2etests' of https://github.com/Az…
lucyzhang929 4fc678f
Merge branch 'dev' into luczhan/addsqlbindinge2etests
gavin-aguiar 8a5d372
fix sql end to end test
lucyzhang929 ea6d214
Merge branch 'luczhan/addsqlbindinge2etests' of https://github.com/Az…
lucyzhang929 b2b4b84
Merge branch 'dev' into luczhan/addsqlbindinge2etests
gavin-aguiar 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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. | ||
|
|
||
| import json | ||
| import azure.functions as func | ||
|
|
||
|
|
||
| def main(req: func.HttpRequest, products: func.SqlRowList) -> func.HttpResponse: | ||
| rows = list(map(lambda r: json.loads(r.to_json()), products)) | ||
|
|
||
| return func.HttpResponse( | ||
| json.dumps(rows), | ||
| status_code=200, | ||
| mimetype="application/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,27 @@ | ||
| { | ||
| "scriptFile": "__init__.py", | ||
| "bindings": [ | ||
| { | ||
| "authLevel": "function", | ||
| "name": "req", | ||
| "type": "httpTrigger", | ||
| "direction": "in", | ||
| "methods": [ | ||
| "get" | ||
| ] | ||
| }, | ||
| { | ||
| "name": "$return", | ||
| "type": "http", | ||
| "direction": "out" | ||
| }, | ||
| { | ||
| "name": "products", | ||
| "type": "sql", | ||
| "direction": "in", | ||
| "commandText": "SELECT * FROM Products", | ||
| "commandType": "Text", | ||
| "connectionStringSetting": "AzureWebJobsSqlConnectionString" | ||
| } | ||
| ] | ||
| } |
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,17 @@ | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. | ||
|
|
||
| import json | ||
| import azure.functions as func | ||
|
|
||
|
|
||
| def main(req: func.HttpRequest, r: func.Out[func.SqlRow]) -> func.HttpResponse: | ||
| body = json.loads(req.get_body()) | ||
| row = func.SqlRow.from_dict(body) | ||
| r.set(row) | ||
|
|
||
| return func.HttpResponse( | ||
| body=req.get_body(), | ||
| status_code=201, | ||
| mimetype="application/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": [ | ||
| { | ||
| "authLevel": "function", | ||
| "name": "req", | ||
| "type": "httpTrigger", | ||
| "direction": "in", | ||
| "methods": [ | ||
| "post" | ||
| ] | ||
| }, | ||
| { | ||
| "name": "$return", | ||
| "type": "http", | ||
| "direction": "out" | ||
| }, | ||
| { | ||
| "name": "r", | ||
| "type": "sql", | ||
| "direction": "out", | ||
| "commandText": "[dbo].[Products]", | ||
| "connectionStringSetting": "AzureWebJobsSqlConnectionString" | ||
| } | ||
| ] | ||
| } |
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,24 @@ | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. | ||
| import json | ||
|
|
||
| from azure_functions_worker import testutils | ||
|
|
||
|
|
||
| class TestSqlFunctions(testutils.WebHostTestCase): | ||
|
|
||
| @classmethod | ||
| def get_script_dir(cls): | ||
| return testutils.E2E_TESTS_FOLDER / 'sql_functions' | ||
|
|
||
| @testutils.retryable_test(3, 5) | ||
| def test_sql_output_and_input(self): | ||
| row = {"ProductId": 0, "Name": "test", "Cost": 100} | ||
| r = self.webhost.request('POST', 'sql_output', | ||
| data=json.dumps(row)) | ||
| self.assertEqual(r.status_code, 201) | ||
|
|
||
| r = self.webhost.request('GET', 'sql_input') | ||
| self.assertEqual(r.status_code, 200) | ||
| expectedText = "[{\"ProductId\": 0, \"Name\": \"test\", \"Cost\": 100}]" | ||
| self.assertEqual(r.text, expectedText) |
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.