Advanced
Testing
Testing a Framework application is easy. Given that event handlers are plain Python functions that take arguments such as state
and payload
, you can inject your own and test whether the outcome is correct. This section will use pytest
examples.
State
Accessing the initial state
To get started, import your app’s entry point, main
. This will initialise state and make event handlers available. The initial state is available in the module, at main.wf.initial_state
provided you imported writer
as wf
.
Creating states
For testing purposes, you can create your own state using the WriterState
class in writer.core
. Pass a dictionary when constructing it.
Example
The code of a Framework application basically consists of two things:
- Initial state
- Event handlers
It’s straightforward to test both, as shown below.