Following is my python module my_func.py
def get_data(request):
function_1(request)
I want to test if function_1
is called with correct request
argument inside get_data()
function and the following test works fine.
class GetDataTest(TestCase):
@patch("my_func.function_1", autospec=True)
def test_get_data(self, function_1_mock):
request_mock = MagicMock()
my_func.get_metadata(request_mock)
function_1_mock.assert_called_once_with(request_mock)
If I change my python module my_func.py
to the following where I have an array of functions then I'm struggling how to mock functions individually.
functions = [
function_1,
function_2,
function_3
]
def get_data(request):
for function in functions:
function(request)