What you can do is ensure the following:
Correct Mock Path: Make sure that the path in patch()
matches where create_memcache_item
is used in your code.
Patch Scope: The patch()
context should wrap the entire interaction with the endpoint to ensure the mock is used instead of the actual function.
Consistent Return Value: Mock create_memcache_item
to return a consistent value (e.g., milliseconds
).
Response Format: Also, verify the return value matches the expected format in your assertions.