I want to mock a function call that functions as an Avro deserializer and yields the decoded results.
What I want is to have it mocked with the encoded values and have the return value set as the deserialized value I pass in the test case.
I am unsure how to set this up because I don't want the function to actually be called. When I tried to set it up like this:
@patch('myModule.deserialize_generator')
def test_serialized_data_conversion(self, get_content_mock):
schema_url = "mock_url"
serialized_content = load_fixture("serialized_content.json")
expected_deserialized_content = load_fixture("deserialized_content.json")
get_content_mock.return_value = MagicMock(status_code=200, response=expected_deserialized_content)
self.assertEqual(deserialize_generator(serialized_content, schema_url, logger), expected_deserialized_content)
It tries to call the function as is and will return an error since it expects certain secret values.
So how can I set this up so that it doesn't actually call the function "deserialize_generator" and simply mocks the response?