-
Notifications
You must be signed in to change notification settings - Fork 107
test: add ServiceBus SDK tests #1678
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 35 commits into
dev
from
extensions/azurefunctions-extensions-bindings-servicebus/1.0.0b1
Sep 17, 2025
Merged
Changes from 9 commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
9f91548
Add servicebus sdk worker tests
hallvictoria 43e4b4f
Add as part of current sb tests
hallvictoria b43cd48
remove old file
hallvictoria b1d88ee
renaming
hallvictoria f92b5a2
fixes + refactor blob sdk to emulator
hallvictoria 3078d4d
directory fix
hallvictoria a6b1d0d
directory fix
hallvictoria ab038f4
Merge branch 'dev' of https://github.com/Azure/azure-functions-python…
hallvictoria fad1242
rename sb directory
hallvictoria d30a219
move emulator connection strings to variable groups
hallvictoria a3cf630
same for unit tests
hallvictoria 4ade5eb
add sb topic tests
hallvictoria c9a239a
Revert me later
hallvictoria 56709da
remove topic tests
hallvictoria f303344
Add snake case tests + remove topic test + single sb batch test
hallvictoria b484718
dir fix
hallvictoria d9cf250
fix tests
hallvictoria 90d1302
merge with dev
hallvictoria b0133f7
remove testqueue-batch + debugging e2e
hallvictoria 172bf2b
remove debug log
hallvictoria 42e537e
fix eg connection reference
hallvictoria 549c5d7
move emulator var group to separate file
hallvictoria 551568a
off
hallvictoria 9ee925b
fix merge conflicts
hallvictoria 06bbd0f
lint
hallvictoria ca2ee66
Merge branch 'dev' into extensions/azurefunctions-extensions-bindings…
hallvictoria 7c8e9b5
remove batch
hallvictoria a466c91
merge fixes
hallvictoria e8af8dc
fix test dir
hallvictoria 6e3b7f3
fix test dir pt 2
hallvictoria 31206d8
fix miss
hallvictoria 9eb1723
Merge branch 'dev' into extensions/azurefunctions-extensions-bindings…
hallvictoria 209f352
remove v1 tests
hallvictoria e27bcb6
fix tests
hallvictoria 0c84dab
lint
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
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
51 changes: 51 additions & 0 deletions
51
tests/emulator_tests/servicebus_functions/servicebus_functions_sdk/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,51 @@ | ||
| import json | ||
| import jsonpickle | ||
|
|
||
| import azure.functions as func | ||
| import azurefunctions.extensions.bindings.servicebus as sb | ||
|
|
||
| app = func.FunctionApp(http_auth_level=func.AuthLevel.ANONYMOUS) | ||
|
|
||
|
|
||
| @app.route(route="put_message_sdk") | ||
| @app.service_bus_queue_output( | ||
| arg_name="msg", | ||
| connection="AzureWebJobsServiceBusSDKConnectionString", | ||
| queue_name="testqueue") | ||
| def put_message_sdk(req: func.HttpRequest, msg: func.Out[str]): | ||
| msg.set(req.get_body().decode('utf-8')) | ||
| return 'OK' | ||
|
|
||
|
|
||
| @app.route(route="get_servicebus_triggered_sdk") | ||
| @app.blob_input(arg_name="file", | ||
| path="python-worker-tests/test-servicebus-sdk-triggered.txt", | ||
| connection="AzureWebJobsStorage") | ||
| def get_servicebus_triggered_sdk(req: func.HttpRequest, | ||
| file: func.InputStream) -> str: | ||
| return func.HttpResponse( | ||
| file.read().decode('utf-8'), mimetype='application/json') | ||
|
|
||
|
|
||
| @app.service_bus_queue_trigger( | ||
| arg_name="msg", | ||
| connection="AzureWebJobsServiceBusSDKConnectionString", | ||
| queue_name="testqueue") | ||
hallvictoria marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| @app.blob_output(arg_name="$return", | ||
| path="python-worker-tests/test-servicebus-sdk-triggered.txt", | ||
| connection="AzureWebJobsStorage") | ||
| def servicebus_trigger_sdk(msg: sb.ServiceBusReceivedMessage) -> str: | ||
| msg_json = jsonpickle.encode(msg) | ||
| body_json = jsonpickle.encode(msg.body) | ||
| enqueued_time_json = jsonpickle.encode(msg.enqueued_time_utc) | ||
| lock_token_json = jsonpickle.encode(msg.lock_token) | ||
| result = json.dumps({ | ||
| 'message': msg_json, | ||
| 'body': body_json, | ||
| 'enqueued_time_utc': enqueued_time_json, | ||
| 'lock_token': lock_token_json, | ||
| 'message_id': msg.message_id, | ||
| 'sequence_number': msg.sequence_number | ||
| }) | ||
|
|
||
| return result | ||
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
Oops, something went wrong.
Oops, something went wrong.
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.