Updating mocked activity's return value

Hi!

I’m testing a workflow with the Python SDK and following those docs. The workflow I’m testing uses two activities. I’ve mocked both in the style provided here but I’m running into a new issue with one of these. I need to update the return value of the first activity. In the past, I’ve updated the return values of mocks using unittest.mock, (mock_function.return_value = “new value”) but I can’t find a way to mock temporal activities using that method. Has anyone encountered this before?

As a brief example- activity_one checks the status of some data. activity_two updates that data. activity_one runs again, and I would like it to return the updated data the second time.

activity_one --> returns "false"
activity_two --> updates data to "true"
activity_one --> returns "true"

activity_one is defined as:

@activity.defn(name="activity_one")
async def activity_one_mocked(input: data_id) -> bool:
    return false

Which works brilliantly the first time, but needs to be updated to return true

Any advice is greatly appreciated!

Maybe a bit of a hack but you could in your mock activity get activity id via
activity.info().activity_id

this is incremented (starting at 1) by worker for each scheduled activity, in your case first call to activity_one would get 1, and 3 for second call if this helps