I'm trying to return a list from Mock object but can't get it to work.
That's the code:
def execute_call(model, payload):
result = model.execute(payload)
code = result[0]
Here's the test I have tried:
def test_get_code(self, session):
execute_call = Mock()
execute_call.return_value = ['123', '123', '123']
session.return_value = Mock(execute=execute_call)
Result:
code = result[0]
TypeError: 'Mock' object does not support indexing
I can't figure out how to make result[0] to work. 'execute_call' should be mock, but the return_value would need to be a list.
Any idea is appreciated.