Skip to content

Commit

Permalink
README
Browse files Browse the repository at this point in the history
  • Loading branch information
cecheta committed May 13, 2024
1 parent aab3071 commit 3dc1f7f
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion code/tests/functional/tests/functions/README.md
Original file line number Diff line number Diff line change
@@ -1 +1,33 @@
wip
# Azure Functions Tests

The functional tests for Azure Functions do not run the Azure functions locally, but instead invoke the entrypoints of the Python functions directly within each test.

For example, consider the following:

```py
import azure.functions as func

app = func.FunctionApp()

@app.function_name(name="HttpTrigger1")
@app.route(route="req")
def main(req):
user = req.params.get("user")
return f"Hello, {user}!"
```

Instead of making an HTTP request to `/api/req` from within a test, import the function directly and call the function with a payload similar to what would be
expected when running in Azure.


```py
req = func.HttpRequest(
method="GET",
url="http://localhost:7071/api/req",
body=b"",
)

main.build().get_user_function()(req)
```

Downstream dependcies are mocked using [pytest-httpserver](https://pytest-httpserver.readthedocs.io/).

0 comments on commit 3dc1f7f

Please sign in to comment.