From 0906eb019d11f428603cf3d429cc823615c2d7ad Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Tue, 31 Jul 2018 10:05:10 +0100 Subject: [PATCH] Check that API is not called when result is cached Good to explicitly test this (rather than relying on an exception not being raised). --- tests/app/notify_client/test_job_client.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/app/notify_client/test_job_client.py b/tests/app/notify_client/test_job_client.py index f4c570a9d..0b39da02e 100644 --- a/tests/app/notify_client/test_job_client.py +++ b/tests/app/notify_client/test_job_client.py @@ -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) )