Say I have a flow class app1/flows.py
class MyFlow(Flow):
start = ...
do_stuff = flow.Handler(this.do_stuff_handler).Next(...)
end = ...
def do_stuff_handler(self, activation):
...
If I want to mock do_stuff_handler
to assert if it has been called
class MyFlowTest(TestCase):
@mock.patch('app1.flows.MyFlow.do_stuff_handler')
def test_do_stuff_handler_called(self, mock_do_stuff_handler):
...
It appears the do_stuff_handler
did not get patched. I did notice the flow class gets instantiated when starting up Django see here I am struggling to find the correct path to patch the handler method. Any ideas?
this-references are resolved at a class import time, and kept inside flow.Handler member variable.
So I think mocking the app1.flows.MyFlow.instance.do_stuff.handler
could helps