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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest_zeebe-0.1.1.tar.gz (34.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytest_zeebe-0.1.1-py3-none-any.whl (41.3 kB view details)

Uploaded Python 3

File details

Details for the file pytest_zeebe-0.1.1.tar.gz.

File metadata

  • Download URL: pytest_zeebe-0.1.1.tar.gz
  • Upload date:
  • Size: 34.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.11.3 Linux/6.2.0-1019-azure

File hashes

Hashes for pytest_zeebe-0.1.1.tar.gz
Algorithm Hash digest
SHA256 41f8b72894209405c37974a9d7a1ad227bd11973a8cefb08f801047e4bbce4bf
MD5 69be23714d0d81111ee780eed458b728
BLAKE2b-256 56772478a8e0d05581ad26329f0c5583c8828963180b7af0543fdb6b43fb622e

See more details on using hashes here.

File details

Details for the file pytest_zeebe-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: pytest_zeebe-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 41.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.11.3 Linux/6.2.0-1019-azure

File hashes

Hashes for pytest_zeebe-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 097c99ee38dcae74866aec8248dca59c0df81f328d2ffc9750663a77959a0c44
MD5 0552522b626d30d54c74fff5cddd20d7
BLAKE2b-256 63d1c382f0728fed3f142b14628194bfc91fd6bc8c5c549737b791839787e430

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page