-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Victoria Hall
committed
Dec 18, 2024
1 parent
40ce8b4
commit 5f6e2a9
Showing
20 changed files
with
465 additions
and
97 deletions.
There are no files selected for viewing
This file contains 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 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 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 was deleted.
Oops, something went wrong.
This file contains 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
8 changes: 8 additions & 0 deletions
8
tests/emulator_tests/servicebus_functions/get_servicebus_triggered/__init__.py
This file contains 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,8 @@ | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. | ||
import azure.functions as func | ||
|
||
|
||
def main(req: func.HttpRequest, file: func.InputStream) -> str: | ||
return func.HttpResponse( | ||
file.read().decode('utf-8'), mimetype='application/json') |
23 changes: 23 additions & 0 deletions
23
tests/emulator_tests/servicebus_functions/get_servicebus_triggered/function.json
This file contains 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,23 @@ | ||
{ | ||
"scriptFile": "__init__.py", | ||
"bindings": [ | ||
{ | ||
"type": "httpTrigger", | ||
"direction": "in", | ||
"name": "req", | ||
"authLevel": "anonymous" | ||
}, | ||
{ | ||
"type": "blob", | ||
"direction": "in", | ||
"name": "file", | ||
"connection": "AzureWebJobsStorage", | ||
"path": "python-worker-tests/test-servicebus-triggered.txt" | ||
}, | ||
{ | ||
"type": "http", | ||
"direction": "out", | ||
"name": "$return", | ||
} | ||
] | ||
} |
9 changes: 9 additions & 0 deletions
9
tests/emulator_tests/servicebus_functions/put_message/__init__.py
This file contains 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,9 @@ | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. | ||
import azure.functions as azf | ||
|
||
|
||
def main(req: azf.HttpRequest, msg: azf.Out[str]): | ||
msg.set(req.get_body().decode('utf-8')) | ||
|
||
return 'OK' |
24 changes: 24 additions & 0 deletions
24
tests/emulator_tests/servicebus_functions/put_message/function.json
This file contains 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 @@ | ||
{ | ||
"scriptFile": "__init__.py", | ||
|
||
"bindings": [ | ||
{ | ||
"type": "httpTrigger", | ||
"direction": "in", | ||
"name": "req", | ||
"authLevel": "anonymous" | ||
}, | ||
{ | ||
"direction": "out", | ||
"name": "msg", | ||
"queueName": "testqueue", | ||
"connection": "AzureWebJobsServiceBusConnectionString", | ||
"type": "serviceBus" | ||
}, | ||
{ | ||
"direction": "out", | ||
"name": "$return", | ||
"type": "http" | ||
} | ||
] | ||
} |
73 changes: 73 additions & 0 deletions
73
tests/emulator_tests/servicebus_functions/servicebus_functions_stein/function_app.py
This file contains 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,73 @@ | ||
import json | ||
|
||
import azure.functions as func | ||
|
||
app = func.FunctionApp(http_auth_level=func.AuthLevel.ANONYMOUS) | ||
|
||
|
||
@app.route(route="put_message") | ||
@app.service_bus_queue_output( | ||
arg_name="msg", | ||
connection="AzureWebJobsServiceBusConnectionString", | ||
queue_name="testqueue") | ||
def put_message(req: func.HttpRequest, msg: func.Out[str]): | ||
msg.set(req.get_body().decode('utf-8')) | ||
return 'OK' | ||
|
||
|
||
@app.route(route="get_servicebus_triggered") | ||
@app.blob_input(arg_name="file", | ||
path="python-worker-tests/test-servicebus-triggered.txt", | ||
connection="AzureWebJobsStorage") | ||
def get_servicebus_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="msg", | ||
connection="AzureWebJobsServiceBusConnectionString", | ||
queue_name="testqueue") | ||
@app.blob_output(arg_name="$return", | ||
path="python-worker-tests/test-servicebus-triggered.txt", | ||
connection="AzureWebJobsStorage") | ||
def servicebus_trigger(msg: func.ServiceBusMessage) -> str: | ||
result = json.dumps({ | ||
'message_id': msg.message_id, | ||
'body': msg.get_body().decode('utf-8'), | ||
'content_type': msg.content_type, | ||
'delivery_count': msg.delivery_count, | ||
'expiration_time': (msg.expiration_time.isoformat() if | ||
msg.expiration_time else None), | ||
'label': msg.label, | ||
'partition_key': msg.partition_key, | ||
'reply_to': msg.reply_to, | ||
'reply_to_session_id': msg.reply_to_session_id, | ||
'scheduled_enqueue_time': (msg.scheduled_enqueue_time.isoformat() if | ||
msg.scheduled_enqueue_time else None), | ||
'session_id': msg.session_id, | ||
'time_to_live': msg.time_to_live, | ||
'to': msg.to, | ||
'user_properties': msg.user_properties, | ||
|
||
'application_properties': msg.application_properties, | ||
'correlation_id': msg.correlation_id, | ||
'dead_letter_error_description': msg.dead_letter_error_description, | ||
'dead_letter_reason': msg.dead_letter_reason, | ||
'dead_letter_source': msg.dead_letter_source, | ||
'enqueued_sequence_number': msg.enqueued_sequence_number, | ||
'enqueued_time_utc': (msg.enqueued_time_utc.isoformat() if | ||
msg.enqueued_time_utc else None), | ||
'expires_at_utc': (msg.expires_at_utc.isoformat() if | ||
msg.expires_at_utc else None), | ||
'locked_until': (msg.locked_until.isoformat() if | ||
msg.locked_until else None), | ||
'lock_token': msg.lock_token, | ||
'sequence_number': msg.sequence_number, | ||
'state': msg.state, | ||
'subject': msg.subject, | ||
'transaction_partition_key': msg.transaction_partition_key | ||
}) | ||
|
||
return result |
81 changes: 81 additions & 0 deletions
81
tests/emulator_tests/servicebus_functions/servicebus_functions_stein/generic/function_app.py
This file contains 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,81 @@ | ||
import json | ||
|
||
import azure.functions as func | ||
|
||
app = func.FunctionApp(http_auth_level=func.AuthLevel.ANONYMOUS) | ||
|
||
|
||
@app.function_name(name="put_message") | ||
@app.generic_trigger(arg_name="req", type="httpTrigger", route="put_message") | ||
@app.generic_output_binding(arg_name="msg", | ||
type="serviceBus", | ||
connection="AzureWebJobsServiceBusConnectionString", | ||
queue_name="testqueue") | ||
@app.generic_output_binding(arg_name="$return", type="http") | ||
def put_message(req: func.HttpRequest, msg: func.Out[str]): | ||
msg.set(req.get_body().decode('utf-8')) | ||
return 'OK' | ||
|
||
|
||
@app.function_name(name="get_servicebus_triggered") | ||
@app.generic_trigger(arg_name="req", type="httpTrigger", | ||
route="get_servicebus_triggered") | ||
@app.generic_input_binding(arg_name="file", | ||
type="blob", | ||
path="python-worker-tests/test-servicebus-triggered.txt", # NoQA | ||
connection="AzureWebJobsStorage") | ||
@app.generic_output_binding(arg_name="$return", type="http") | ||
def get_servicebus_triggered(req: func.HttpRequest, | ||
file: func.InputStream) -> str: | ||
return func.HttpResponse( | ||
file.read().decode('utf-8'), mimetype='application/json') | ||
|
||
|
||
@app.generic_trigger( | ||
arg_name="msg", | ||
type="serviceBusTrigger", | ||
connection="AzureWebJobsServiceBusConnectionString", | ||
queue_name="testqueue") | ||
@app.generic_output_binding(arg_name="$return", | ||
path="python-worker-tests/test-servicebus-triggered.txt", # NoQA | ||
type="blob", | ||
connection="AzureWebJobsStorage") | ||
def servicebus_trigger(msg: func.ServiceBusMessage) -> str: | ||
result = json.dumps({ | ||
'message_id': msg.message_id, | ||
'body': msg.get_body().decode('utf-8'), | ||
'content_type': msg.content_type, | ||
'delivery_count': msg.delivery_count, | ||
'expiration_time': (msg.expiration_time.isoformat() if | ||
msg.expiration_time else None), | ||
'label': msg.label, | ||
'partition_key': msg.partition_key, | ||
'reply_to': msg.reply_to, | ||
'reply_to_session_id': msg.reply_to_session_id, | ||
'scheduled_enqueue_time': (msg.scheduled_enqueue_time.isoformat() if | ||
msg.scheduled_enqueue_time else None), | ||
'session_id': msg.session_id, | ||
'time_to_live': msg.time_to_live, | ||
'to': msg.to, | ||
'user_properties': msg.user_properties, | ||
|
||
'application_properties': msg.application_properties, | ||
'correlation_id': msg.correlation_id, | ||
'dead_letter_error_description': msg.dead_letter_error_description, | ||
'dead_letter_reason': msg.dead_letter_reason, | ||
'dead_letter_source': msg.dead_letter_source, | ||
'enqueued_sequence_number': msg.enqueued_sequence_number, | ||
'enqueued_time_utc': (msg.enqueued_time_utc.isoformat() if | ||
msg.enqueued_time_utc else None), | ||
'expires_at_utc': (msg.expires_at_utc.isoformat() if | ||
msg.expires_at_utc else None), | ||
'locked_until': (msg.locked_until.isoformat() if | ||
msg.locked_until else None), | ||
'lock_token': msg.lock_token, | ||
'sequence_number': msg.sequence_number, | ||
'state': msg.state, | ||
'subject': msg.subject, | ||
'transaction_partition_key': msg.transaction_partition_key | ||
}) | ||
|
||
return result |
Oops, something went wrong.