Check that API is not called when result is cached

Good to explicitly test this (rather than relying on an exception not
being raised).
This commit is contained in:
Chris Hill-Scott
2018-07-31 10:05:10 +01:00
parent eb8e433820
commit 0906eb019d

View File

@@ -355,12 +355,16 @@ def test_has_jobs_returns_from_cache(
cache_value,
return_value,
):
mock_get = mocker.patch(
'app.notify_client.job_api_client.JobApiClient.get'
)
mock_redis_get = mocker.patch(
'app.notify_client.RedisClient.get',
return_value=cache_value,
)
assert JobApiClient().has_jobs(fake_uuid) is return_value
assert not mock_get.called
mock_redis_get.assert_called_once_with(
'has_jobs-{}'.format(fake_uuid)
)