Open gruyaume opened 2 weeks ago
I don't think this is possible in 6.x (without using a regular unittest/pytest mock).
However, you can do this in (very soon to be released) 7.0:
class TestCharmConfigure(RouterUnitTestFixtures):
def test_given_can_connect_when_configure_then_ip_forwarding_is_set(
self,
):
ip_forward_call = ("sysctl", "-w", "net.ipv4.ip_forward=1")
container = scenario.Container(
name="router",
can_connect=True,
execs={
scenario.Exec(
ip_forward_call, return_code=0, stdout="net.ipv4.ip_forward = 1"
),
},
)
state_in = scenario.State(
leader=True,
containers={container},
)
state_out = self.ctx.run(self.ctx.on.pebble_ready(container), state_in)
assert self.ctx.exec_history[container.name][0].command == ip_forward_call
Description
I am using scenario's
exec_mock
and I can't figure out how to check that my mock was called. Reading the documentation it is not clear whether this is possible.Logs
Reference