Skip to main content

pytest-zeebe

Pytest fixtures for testing Camunda 8 processes in Python using a Zeebe test engine.

Compatible with: Camunda Platform 8 sponsored

🚀 What does it do?

This package provides a set of fixtures to set up Zeebe process tests for Python in no time:

  • automatically spins up a stripped-down Zeebe engine per file/module (same as used by zeebe-process-test)
  • resets engine state before every test
  • injects a ZeebeTestClient to drive the process
  • (optionally) injects a ZeebeTestEngine to await idle state or access raw zeebe records
  • provides rich assertions for the process instance (goal: equal to zeebe-process-test BpmnAssertions)

Install

pip install pytest-zeebe

Example Usage

The engine is reset before every test, so you can create a fixture to deploy your process automatically:

@pytest.fixture(autouse=True)
def deploy(zeebe_test_client: ZeebeTestClient):
    zeebe_test_client.deploy_process("test.bpmn")

With the process deployed, you can start it, complete tasks and make assertions as usual:

def test(zeebe_test_client: ZeebeTestClient):
    # given
    variables = {
        "var": "A"
    }

    # when
    # -> start
    process_instance = zeebe_test_client.create_process_instance("TestProcess", variables=variables)

    # -> complete Task A
    zeebe_test_client.complete_task("taskA")
    
    assert_that(process_instance).is_waiting_at_elements("TaskC")

    # -> complete Task C
    zeebe_test_client.complete_task("taskC", variables={"resultC": True})

    # then
    assert_that(process_instance) \
        .is_completed() \
        .has_passed_elements_in_order("StartEvent_1", "TaskA", "TaskC", "EndEvent_1") \
        .has_variable_with_value("var", "A") \
        .has_variable_with_value("resultC", True) \
        .has_no_incidents()

Known Issues

This package ships with its own grpc zeebe client. Due to the inner workings of protobuf, this will lead to an unresolvable conflict if you also import code from another library that also registers protobuf descriptors for the zeebe gateway protocol (like pyzeebe). This is no issue if you test the process by itself or - for integration tests - start your app in a dedicated process.

License

This library is developed under

Apache 2.0 License

Sponsors and Customers

sponsored

Release files for pytest-zeebe 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytest-zeebe 0.1.2
File Size Uploaded
pytest_zeebe-0.1.2.tar.gz 34.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pytest-zeebe 0.1.2
File Interpreter ABI Platform
pytest_zeebe-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 76.1 kB

Release files / pytest_zeebe-0.1.2.tar.gz

Download URL pytest_zeebe-0.1.2.tar.gz
Size 34.7 kB
Tags Source
SHA-256 checksum
How to use checksums
e01a38c589eb6a03f464e8bd01869cbb6c10868c29b19d3e1950581fa67417e0
BLAKE2b-256 checksum
How to use checksums
e6956cf1bfebc73d12847bc7c07bed261027a68f7f8d8d65d8e69bafd6d04c71
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.7.1 CPython/3.11.3 Linux/6.2.0-1019-azure

Release files / pytest_zeebe-0.1.2-py3-none-any.whl

Download URL pytest_zeebe-0.1.2-py3-none-any.whl
Size 41.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dc56c2fc3f94c2e21833df434b2232b7a0434ecb749ad8a0c416fe14751827f1
BLAKE2b-256 checksum
How to use checksums
c6a7e4b4be8bd81f0d50b0b7921faf5bad460c3a0826061ac21257e807880c04
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.7.1 CPython/3.11.3 Linux/6.2.0-1019-azure

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page