Skip to content

Commit 7471841

Browse files
authored
test: combine unit tests into single pipeline (#81)
* update fastapi docs * combining all tests into one pipeline? * hm * hm pt2 * hm pt3 * remove individual ext tests * fix sb test for 313 * fix sb typo * feedback
1 parent 4f129f9 commit 7471841

File tree

23 files changed

+215
-454
lines changed

23 files changed

+215
-454
lines changed

azurefunctions-extensions-bindings-servicebus/samples/servicebus_samples_batch/function_app.py

-4
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,12 @@ def servicebus_queue_trigger(receivedmessage: List[servicebus.ServiceBusReceived
4343
"Body: %s\n"
4444
"Enqueued time: %s\n"
4545
"Lock Token: %s\n"
46-
"Locked until : %s\n"
4746
"Message ID: %s\n"
4847
"Sequence number: %s\n",
4948
message,
5049
message.body,
5150
message.enqueued_time_utc,
5251
message.lock_token,
53-
message.locked_until,
5452
message.message_id,
5553
message.sequence_number)
5654

@@ -67,13 +65,11 @@ def servicebus_topic_trigger(receivedmessage: List[servicebus.ServiceBusReceived
6765
"Body: %s\n"
6866
"Enqueued time: %s\n"
6967
"Lock Token: %s\n"
70-
"Locked until : %s\n"
7168
"Message ID: %s\n"
7269
"Sequence number: %s\n",
7370
message,
7471
message.body,
7572
message.enqueued_time_utc,
7673
message.lock_token,
77-
message.locked_until,
7874
message.message_id,
7975
message.sequence_number)

azurefunctions-extensions-bindings-servicebus/samples/servicebus_samples_single/function_app.py

-4
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,12 @@ def servicebus_queue_trigger(receivedmessage: servicebus.ServiceBusReceivedMessa
4040
"Body: %s\n"
4141
"Enqueued time: %s\n"
4242
"Lock Token: %s\n"
43-
"Locked until : %s\n"
4443
"Message ID: %s\n"
4544
"Sequence number: %s\n",
4645
receivedmessage,
4746
receivedmessage.body,
4847
receivedmessage.enqueued_time_utc,
4948
receivedmessage.lock_token,
50-
receivedmessage.locked_until,
5149
receivedmessage.message_id,
5250
receivedmessage.sequence_number)
5351

@@ -62,13 +60,11 @@ def servicebus_topic_trigger(receivedmessage: servicebus.ServiceBusReceivedMessa
6260
"Body: %s\n"
6361
"Enqueued time: %s\n"
6462
"Lock Token: %s\n"
65-
"Locked until : %s\n"
6663
"Message ID: %s\n"
6764
"Sequence number: %s\n",
6865
receivedmessage,
6966
receivedmessage.body,
7067
receivedmessage.enqueued_time_utc,
7168
receivedmessage.lock_token,
72-
receivedmessage.locked_until,
7369
receivedmessage.message_id,
7470
receivedmessage.sequence_number)

azurefunctions-extensions-bindings-servicebus/tests/test_servicebus.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,5 @@ def test_input_invalid_datum_type(self):
147147
def test_input_get_decoded_message_ex(self):
148148
with self.assertRaises(ValueError) as e:
149149
_ = get_decoded_message("Invalid message")
150-
self.assertEqual(
151-
e.exception.args[0],
152-
"Failed to decode ServiceBus content: must be str, not bytes",
153-
)
150+
151+
self.assertIn("Failed to decode ServiceBus content", e.exception.args[0])

azurefunctions-extensions-http-fastapi/README.md

+13-9
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ This library contains HttpV2 extensions for FastApi Request/Response types to us
33

44
[Source code](https://github.com/Azure/azure-functions-python-extensions/tree/dev/azurefunctions-extensions-http-fastapi)
55
| [Package (PyPi)](https://pypi.org/project/azurefunctions-extensions-http-fastapi/)
6-
| API reference documentation
7-
| Product documentation
6+
| [Developer Reference](https://learn.microsoft.com/en-us/azure/azure-functions/functions-reference-python?tabs=get-started%2Casgi%2Capplication-level&pivots=python-mode-decorators#http-streams-preview)
87
| [Samples](https://github.com/Azure/azure-functions-python-extensions/tree/dev/azurefunctions-extensions-http-fastapi/samples)
98

109

@@ -16,19 +15,24 @@ This library contains HttpV2 extensions for FastApi Request/Response types to us
1615

1716
### Instructions
1817
1. Follow the guide to [create an app](https://learn.microsoft.com/en-us/azure/azure-functions/create-first-function-cli-python?tabs=windows%2Cbash%2Cazure-cli%2Cbrowser). If you're testing the function locally, make sure to update to the latest version of Core Tools.
19-
2. Ensure your app is using programming model v2 and contains a http trigger function.
18+
2. Ensure your app is using programming model v2 and contains an HttpTrigger function.
2019
3. Add ```azurefunctions-extensions-http-fastapi``` to your requirements.txt
2120
4. Import Request and different types of responses from ```azurefunctions.extensions.http.fastapi``` in your HttpTrigger functions.
2221
5. Change the request and response types to ones imported from ```azurefunctions.extensions.http.fastapi```.
2322
6. Add ```"PYTHON_ENABLE_INIT_INDEXING": "1"``` to your local.settings.json file or App Settings.
24-
6. Run your function app and try it out!
23+
7. Run your function app and try it out!
2524

26-
### Bind to the FastApi-type
27-
The Azure Functions Extensions Http FastApi library for Python allows you to create a function app with FastApi Request or Response types. When your function runs, you will receive the request of FastApi Request type and you can return a FastApi response type instance. FastApi is one of top popular python web framework which provides elegant and powerful request/response types and functionalities to users. With this integration, you are empowered to use request/response the same way as using them in native FastApi. A good example is you can do http streaming upload and streaming download now! Feel free to check out [Fastapi doc](https://fastapi.tiangolo.com/reference/responses/?h=custom) for further reference.
25+
### Bind to the FastApi type
26+
The Azure Functions Extensions HTTP FastApi library for Python allows you to create a function app with FastApi Request or Response types.
27+
When your function runs, you will receive the FastApi Request type, and you can return a FastApi Response type.
28+
29+
FastApi is one of the top Python web frameworks that provides elegant and powerful Request/Response types and functionalities.
30+
With this integration, you are empowered to use Request/Response types the same way as with native FastApi. For example, HTTP streaming
31+
upload and download scenarios are now possible! Please reference the [FastApi documentation](https://fastapi.tiangolo.com/reference/responses/?h=custom) for further information.
2832

2933

3034
```python
31-
# This Azure Function receives streaming data from a client and processes it in real-time.
35+
# This function app receives streaming data from a client and processes it in real-time.
3236
# It demonstrates streaming upload capabilities for scenarios such as uploading large files,
3337
# processing continuous data streams, or handling IoT device data.
3438

@@ -61,9 +65,9 @@ Get started with our [FastApi samples](https://github.com/Azure/azure-functions-
6165

6266
Several samples are available in this GitHub repository. These samples provide example code for additional scenarios commonly encountered while working with FastApi:
6367

64-
* [fastapi_samples_streaming_upload](https://github.com/Azure/azure-functions-python-extensions/tree/dev/azurefunctions-extensions-http-fastapi/samples/fastapi_samples_streaming_upload) - An example on how to send and receiving a streaming request within your function.
68+
* [fastapi_samples_streaming_upload](https://github.com/Azure/azure-functions-python-extensions/tree/dev/azurefunctions-extensions-http-fastapi/samples/fastapi_samples_streaming_upload) - An example on how to send and receive a streaming request within your function.
6569

66-
* [fastapi_samples_streaming_download](https://github.com/Azure/azure-functions-python-extensions/tree/dev/azurefunctions-extensions-http-fastapi/samples/fastapi_samples_streaming_download) - An example on how to send your http response via streaming to the caller.
70+
* [fastapi_samples_streaming_download](https://github.com/Azure/azure-functions-python-extensions/tree/dev/azurefunctions-extensions-http-fastapi/samples/fastapi_samples_streaming_download) - An example on how to send your HTTP response via streaming to the caller.
6771

6872
## Contributing
6973
This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
---
2+
page_type: sample
3+
languages:
4+
- python
5+
products:
6+
- azure
7+
- azure-functions
8+
- azure-functions-extensions
9+
- azurefunctions-extensions-http-fastapi
10+
urlFragment: extension-fastapi-samples
11+
---
12+
13+
# Azure Functions Extension FastAPI library for Python samples
14+
15+
These are code samples that show common scenario operations with the Azure Functions Extension FastAPI library.
16+
17+
These samples relate to FastApi Request and Response types being used as part of a Python Function App. For
18+
information on FastAPI, please see the [FastApi documentation](https://fastapi.tiangolo.com/reference/responses/?h=custom).
19+
20+
* [fastapi_samples_streaming_upload](https://github.com/Azure/azure-functions-python-extensions/tree/dev/azurefunctions-extensions-http-fastapi/samples/fastapi_samples_streaming_upload) - An example on how to send and receive a streaming request within your function.
21+
22+
* [fastapi_samples_streaming_download](https://github.com/Azure/azure-functions-python-extensions/tree/dev/azurefunctions-extensions-http-fastapi/samples/fastapi_samples_streaming_download) - An example on how to send your HTTP response via streaming to the caller.
23+
24+
## Prerequisites
25+
* Python 3.8 or later is required to use this package. For more details, please read our page on [Python Functions version support policy](https://learn.microsoft.com/en-us/azure/azure-functions/functions-versions?tabs=isolated-process%2Cv4&pivots=programming-language-python#languages).
26+
27+
## Setup
28+
29+
1. Install [Core Tools](https://learn.microsoft.com/en-us/azure/azure-functions/functions-run-local?tabs=windows%2Cisolated-process%2Cnode-v4%2Cpython-v2%2Chttp-trigger%2Ccontainer-apps&pivots=programming-language-python)
30+
2. Install the Azure Functions Extension FastAPI library for Python with [pip](https://pypi.org/project/pip/):
31+
32+
```bash
33+
pip install azurefunctions-extensions-http-fastapi
34+
```
35+
36+
3. Clone or download this sample repository
37+
4. Open the sample folder in Visual Studio Code or your IDE of choice.
38+
39+
## Running the samples
40+
41+
1. Open a terminal window and `cd` to the directory that the sample you wish to run is saved in.
42+
2. Install the required dependencies
43+
```bash
44+
pip install -r requirements.txt
45+
```
46+
3. Start the Functions runtime
47+
```bash
48+
func start
49+
```
50+
4. Execute the function by sending an HTTP request to the local endpoint.
51+
52+
## Next steps
53+
54+
Visit the [HTTP Streams in Python reference documentation](https://learn.microsoft.com/en-us/azure/azure-functions/functions-reference-python?tabs=get-started%2Casgi%2Capplication-level&pivots=python-mode-decorators#http-streams-preview) to learn more about how to use HTTP Streams in a Python Function App and the
55+
[FastApi documentation](https://fastapi.tiangolo.com/reference/responses/?h=custom) to learn more about
56+
what you can do with FastAPI.

azurefunctions-extensions-http-fastapi/samples/fastapi_samples_streaming_download/function_app.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# This Azure Function streams real-time sensor data using Server-Sent Events (SSE).
1+
# This function app streams real-time sensor data using Server-Sent Events (SSE).
22
# It simulates a sensor network transmitting temperature and humidity readings,
33
# which can be consumed by IoT dashboards or analytics pipelines.
44

azurefunctions-extensions-http-fastapi/samples/fastapi_samples_streaming_upload/function_app.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# This Azure Function receives streaming data from a client and processes it in real-time.
1+
# This function app receives streaming data from a client and processes it in real-time.
22
# It demonstrates streaming upload capabilities for scenarios such as uploading large files,
33
# processing continuous data streams, or handling IoT device data.
44

eng/ci/ci-base-tests.yml

-35
This file was deleted.

eng/ci/ci-blob-tests.yml

-35
This file was deleted.

eng/ci/ci-cosmos-tests.yml

-35
This file was deleted.

eng/ci/ci-eventhub-tests.yml

-35
This file was deleted.

eng/ci/ci-fastapi-tests.yml

-35
This file was deleted.

0 commit comments

Comments
 (0)