-
Notifications
You must be signed in to change notification settings - Fork 104
Contributor Guide
wangbill edited this page Apr 4, 2024
·
12 revisions
This page explains how to set up the development environment and run tests locally.
You need to have the following installed on your system:
- Python 3.6.x+
- dotnetcore-sdk 2.x
- azure-functions-core-tools 2.x/3.x
- Export
CORE_TOOLS_EXE_PATH
to the installation path Azure Functions Core Tools (e.g. on macOS as installed by brew -/usr/local/bin/func
)
Note: On macOS systems, where zsh is used, you might see some issues. In the meantime, please use bash
to run these commands.
- Clone the repository:
git clone https://github.com/Azure/azure-functions-python-worker.git
- Create a virtual environment:
python3.6 -m venv worker_env
- Activate the virtual environment:
source worker_env/bin/activate
- Change the directory to the root of the cloned repository:
cd azure-functions-python-worker
- Download setup.py extras_require dev packages:
pip install -U -e .[dev]
- Build gRPC message, download WebHost binaries, and build Azure Functions extensions defined in setup.py:
python setup.py develop
python setup.py build
python setup.py webhost
python setup.py extension
- Create a test function app, obtain the
AzureWebJobsStorage
key, and various service connection strings and put them into.testconfig
(no quotes on around ConnectionStrings):
[azure]
storage_key = DefaultEndpointsProtocol=https;...
cosmosdb_key = AccountEndpoint=https://endpoint.documents.azure.com:443/;...
eventhub_key = Endpoint=sb://endpoint.servicebus.windows.net/;...
servicebus_key = Endpoint=sb://endpoint.servicebus.windows.net/;...
eventgrid_topic_uri = https://eventgridendpoint.region.eventgrid.azure.net/api/events
eventgrid_topic_key = event_grid_key
- Activate the dev virtual environment:
source worker_env/bin/activate
- Change the directory to the root of the cloned repository:
cd azure-functions-python-worker
- Run tests with pytest:
# test everything
pytest
# test specifc file : pytest <test.py file location>
pytest tests/unittests/test_mock_eventhub_functions.py
# test specific method : pytest <test.py file location>::<test class>::<test method>
pytest tests/unittests/test_mock_eventhub_functions.py::TestEventHubMockFunctions::test_mock_eventhub_cardinality_one
- Activate the dev virtual environment:
source worker_env/bin/activate
- Change the directory to the root of the cloned repository:
cd azure-functions-python-worker
- Start a local webhost:
python -m azure.worker.testutils <directory-with-python-functions>
Currently, the WebHost dependency is specified as an Appveyor artifact
url in WEBHOST_URL
in setup.py
.
Alternatively, download/build manually and then specify the full path to
Microsoft.Azure.WebJobs.Script.WebHost.dll
either in the
PYAZURE_WEBHOST_PATH
environment variable, or in the .testconfig
(no quotes on around dll path) configuration file:
[webhost]
dll = <path to Microsoft.Azure.WebJobs.Script.WebHost.dll>
- Activate the dev virtual environment:
source worker_env/bin/activate
- Change the directory to the root of the cloned repository / docs:
cd azure-functions-python-worker/docs
- Ensure that sphinx package is installed:
pip install sphinx
- Build the docs!
make html