Skip to content

test: combine unit tests into single pipeline #81

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 11 commits into from
May 14, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,12 @@ def servicebus_queue_trigger(receivedmessage: List[servicebus.ServiceBusReceived
"Body: %s\n"
"Enqueued time: %s\n"
"Lock Token: %s\n"
"Locked until : %s\n"
"Message ID: %s\n"
"Sequence number: %s\n",
message,
message.body,
message.enqueued_time_utc,
message.lock_token,
message.locked_until,
message.message_id,
message.sequence_number)

Expand All @@ -67,13 +65,11 @@ def servicebus_topic_trigger(receivedmessage: List[servicebus.ServiceBusReceived
"Body: %s\n"
"Enqueued time: %s\n"
"Lock Token: %s\n"
"Locked until : %s\n"
"Message ID: %s\n"
"Sequence number: %s\n",
message,
message.body,
message.enqueued_time_utc,
message.lock_token,
message.locked_until,
message.message_id,
message.sequence_number)
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,12 @@ def servicebus_queue_trigger(receivedmessage: servicebus.ServiceBusReceivedMessa
"Body: %s\n"
"Enqueued time: %s\n"
"Lock Token: %s\n"
"Locked until : %s\n"
"Message ID: %s\n"
"Sequence number: %s\n",
receivedmessage,
receivedmessage.body,
receivedmessage.enqueued_time_utc,
receivedmessage.lock_token,
receivedmessage.locked_until,
receivedmessage.message_id,
receivedmessage.sequence_number)

Expand All @@ -62,13 +60,11 @@ def servicebus_topic_trigger(receivedmessage: servicebus.ServiceBusReceivedMessa
"Body: %s\n"
"Enqueued time: %s\n"
"Lock Token: %s\n"
"Locked until : %s\n"
"Message ID: %s\n"
"Sequence number: %s\n",
receivedmessage,
receivedmessage.body,
receivedmessage.enqueued_time_utc,
receivedmessage.lock_token,
receivedmessage.locked_until,
receivedmessage.message_id,
receivedmessage.sequence_number)
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,5 @@ def test_input_invalid_datum_type(self):
def test_input_get_decoded_message_ex(self):
with self.assertRaises(ValueError) as e:
_ = get_decoded_message("Invalid message")
self.assertEqual(
e.exception.args[0],
"Failed to decode ServiceBus content: must be str, not bytes",
)

self.assertIn("Failed to decode ServiceBus content", e.exception.args[0])
22 changes: 13 additions & 9 deletions azurefunctions-extensions-http-fastapi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ This library contains HttpV2 extensions for FastApi Request/Response types to us

[Source code](https://github.com/Azure/azure-functions-python-extensions/tree/dev/azurefunctions-extensions-http-fastapi)
| [Package (PyPi)](https://pypi.org/project/azurefunctions-extensions-http-fastapi/)
| API reference documentation
| Product documentation
| [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)
| [Samples](https://github.com/Azure/azure-functions-python-extensions/tree/dev/azurefunctions-extensions-http-fastapi/samples)


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

### Instructions
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.
2. Ensure your app is using programming model v2 and contains a http trigger function.
2. Ensure your app is using programming model v2 and contains an HttpTrigger function.
3. Add ```azurefunctions-extensions-http-fastapi``` to your requirements.txt
4. Import Request and different types of responses from ```azurefunctions.extensions.http.fastapi``` in your HttpTrigger functions.
5. Change the request and response types to ones imported from ```azurefunctions.extensions.http.fastapi```.
6. Add ```"PYTHON_ENABLE_INIT_INDEXING": "1"``` to your local.settings.json file or App Settings.
6. Run your function app and try it out!
7. Run your function app and try it out!

### Bind to the FastApi-type
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.
### Bind to the FastApi type
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 FastApi Request type, and you can return a FastApi Response type.

FastApi is one of the top Python web frameworks that provides elegant and powerful Request/Response types and functionalities.
With this integration, you are empowered to use Request/Response types the same way as with native FastApi. For example, HTTP streaming
upload and download scenarios are now possible! Please reference the [FastApi documentation](https://fastapi.tiangolo.com/reference/responses/?h=custom) for further information.


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

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

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

* [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.
* [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.

* [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.
* [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.

## Contributing
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.
Expand Down
56 changes: 56 additions & 0 deletions azurefunctions-extensions-http-fastapi/samples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
---
page_type: sample
languages:
- python
products:
- azure
- azure-functions
- azure-functions-extensions
- azurefunctions-extensions-http-fastapi
urlFragment: extension-fastapi-samples
---

# Azure Functions Extension FastAPI library for Python samples

These are code samples that show common scenario operations with the Azure Functions Extension FastAPI library.

These samples relate to FastApi Request and Response types being used as part of a Python Function App. For
information on FastAPI, please see the [FastApi documentation](https://fastapi.tiangolo.com/reference/responses/?h=custom).

* [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.

* [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.

## Prerequisites
* 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).

## Setup

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)
2. Install the Azure Functions Extension FastAPI library for Python with [pip](https://pypi.org/project/pip/):

```bash
pip install azurefunctions-extensions-http-fastapi
```

3. Clone or download this sample repository
4. Open the sample folder in Visual Studio Code or your IDE of choice.

## Running the samples

1. Open a terminal window and `cd` to the directory that the sample you wish to run is saved in.
2. Install the required dependencies
```bash
pip install -r requirements.txt
```
3. Start the Functions runtime
```bash
func start
```
4. Execute the function by sending an HTTP request to the local endpoint.

## Next steps

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
[FastApi documentation](https://fastapi.tiangolo.com/reference/responses/?h=custom) to learn more about
what you can do with FastAPI.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This Azure Function streams real-time sensor data using Server-Sent Events (SSE).
# This function app streams real-time sensor data using Server-Sent Events (SSE).
# It simulates a sensor network transmitting temperature and humidity readings,
# which can be consumed by IoT dashboards or analytics pipelines.

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

Expand Down
35 changes: 0 additions & 35 deletions eng/ci/ci-base-tests.yml

This file was deleted.

35 changes: 0 additions & 35 deletions eng/ci/ci-blob-tests.yml

This file was deleted.

35 changes: 0 additions & 35 deletions eng/ci/ci-cosmos-tests.yml

This file was deleted.

35 changes: 0 additions & 35 deletions eng/ci/ci-eventhub-tests.yml

This file was deleted.

35 changes: 0 additions & 35 deletions eng/ci/ci-fastapi-tests.yml

This file was deleted.

Loading