This may be a simple question, but I'm new to mock testing, and cant get my head around on how to make this work.
I have a code like this
def check_item(item):
<do some processing>
return processed_item
Basically I'm trying to mock this function with multiple items, and respective return values. for example, if item is apple return value is processed_apple, if its an orange, returned value is processed_orange etc.
So far, I'm trying to write a test case, and stuck with the below
import my_module
from unittest.mock import patch
@patch("my_module.check_item")
def test_check_item(self, check_item):
check_item.assert_called_once_with("apple")
check_item.return_value = 'processed_apple'
Not sure, If Im doing right (or the correct way). And how can I check multiple arguments with different set of return value for each arguments?