Context (Scenario)
Scenario > Context
In Scenario, the Context
object represents the charm code and all of the metadata that is associated with it.
Scenario is about simulating events on charms.
The Context encapsulates:
- what charm type should be instantiated and passed to
ops.main
when the event emission is simulated - what is in the charm’s
metadata.yaml
,actions.yaml
,config.yaml
metadata files - what is the charm execution root (a temporary directory and its contents when the charm is executed)
Usage
from scenario import Context, State
from charm import MyCharm
ctx = Context(
charm_type=MyCharm,
meta={'name': 'my-charm'}
)
state_out: State = ctx.run('start', State())
Last updated 22 days ago.