-
Notifications
You must be signed in to change notification settings - Fork 108
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
Open
hallvictoria
wants to merge
16
commits into
dev
Choose a base branch
from
extensions/azurefunctions-extensions-bindings-servicebus/1.0.0b1
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
16 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 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
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
43 changes: 43 additions & 0 deletions
43
...mulator_tests/servicebus_batch_functions/servicebus_batch_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,43 @@ | ||
import json | ||
|
||
import azure.functions as func | ||
|
||
app = func.FunctionApp(http_auth_level=func.AuthLevel.ANONYMOUS) | ||
|
||
|
||
@app.route(route="servicebus_output_batch") | ||
@app.service_bus_queue_output( | ||
arg_name="msg", | ||
connection="AzureWebJobsServiceBusConnectionString", | ||
queue_name="testqueue-batch") | ||
def servicebus_output_batch(req: func.HttpRequest, msg: func.Out[str]): | ||
msg.set(req.get_body().decode('utf-8')) | ||
return 'OK' | ||
|
||
|
||
@app.route(route="get_servicebus_batch_triggered") | ||
@app.blob_input(arg_name="file", | ||
path="python-worker-tests/test-servicebus-batch-triggered.txt", | ||
connection="AzureWebJobsStorage") | ||
def get_servicebus_batch_triggered(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="events", | ||
connection="AzureWebJobsServiceBusConnectionString", | ||
queue_name="testqueue-batch", | ||
cardinality="many") | ||
@app.blob_output(arg_name="$return", | ||
path="python-worker-tests/test-servicebus-batch-triggered.txt", | ||
connection="AzureWebJobsStorage") | ||
def servicebus_multiple(events) -> str: | ||
table_entries = [] | ||
for event in events: | ||
json_entry = event.get_body().decode('utf-8') | ||
table_entry = json.loads(json_entry) | ||
table_entries.append(table_entry) | ||
table_json = json.dumps(table_entries) | ||
return table_json |
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") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we add a test for SB topics? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does the extension support topics? |
||
@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.