From 45579c59cdfb7d9765661ae7d456ed014ebf2f75 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Tue, 31 Jul 2018 12:17:28 +0100 Subject: [PATCH] Store boolean values in Redis as valid JSON Calling `.set()` with `True` stores the byte string `'True'` which cannot subsequently be decoded from JSON (because boolean values in JSON are lowercase, ie `true`). --- app/notify_client/job_api_client.py | 2 +- tests/app/notify_client/test_job_client.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/notify_client/job_api_client.py b/app/notify_client/job_api_client.py index c214cc447..75e5ddd7a 100644 --- a/app/notify_client/job_api_client.py +++ b/app/notify_client/job_api_client.py @@ -90,7 +90,7 @@ class JobApiClient(NotifyAdminAPIClient): self.redis_client.set( 'has_jobs-{}'.format(service_id), - True, + b'true', ex=cache.TTL, ) diff --git a/tests/app/notify_client/test_job_client.py b/tests/app/notify_client/test_job_client.py index 0b39da02e..58c457f35 100644 --- a/tests/app/notify_client/test_job_client.py +++ b/tests/app/notify_client/test_job_client.py @@ -29,7 +29,7 @@ def test_client_creates_job_data_correctly(mocker, fake_uuid): mock_post.assert_called_once_with(url=expected_url, data=expected_data) mock_redis_set.assert_called_once_with( 'has_jobs-{}'.format(service_id), - True, + b'true', ex=604800, )