Skip to content

Enable AddProductParam test for Python #618

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 2 commits into from
Jan 9, 2023
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
6 changes: 5 additions & 1 deletion samples/samples-python/AddProductParams/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.

from urllib.parse import parse_qs, urlparse

import azure.functions as func
from Common.product import Product

def main(req: func.HttpRequest, product: func.Out[func.SqlRow]) -> func.HttpResponse:
row = func.SqlRow(Product(req.params["productId"], req.params["name"], req.params["cost"]))
# The Python worker discards empty query parameters so use parse_qs as a workaround.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we document this somewhere or is this just temporary (is the Python worker going to change this behavior?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Waiting on the Python worker team's response on the issue Azure/azure-functions-python-worker#894

params = parse_qs(urlparse(req.url).query, keep_blank_values=True)
row = func.SqlRow(Product(params["productId"][0], params["name"][0], params["cost"][0]))
product.set(row)

return func.HttpResponse(
Expand Down
4 changes: 2 additions & 2 deletions test/Integration/SqlOutputBindingIntegrationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ public void AddProductTest(int id, string name, int cost, SupportedLanguages lan
[SqlInlineData(1, "Test", 5)]
[SqlInlineData(0, "", 0)]
[SqlInlineData(-500, "ABCD", 580)]
// Currently Java and Python functions return null when the parameter for name is an empty string
// Currently Java functions return null when the parameter for name is an empty string
// Issue link: https://github.com/Azure/azure-functions-sql-extension/issues/517
[UnsupportedLanguages(SupportedLanguages.Java, SupportedLanguages.Python)]
[UnsupportedLanguages(SupportedLanguages.Java)]
public void AddProductParamsTest(int id, string name, int cost, SupportedLanguages lang)
{
this.StartFunctionHost(nameof(AddProductParams), lang);
Expand Down