From 075ac1f3d385fa4e15c0f325492ef9d65cd1e145 Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Fri, 19 Apr 2024 10:12:27 -0700 Subject: [PATCH 1/2] use raw_get and raw_set for better debug of redis --- app/service_invite/rest.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/service_invite/rest.py b/app/service_invite/rest.py index 2c666b92f..81dcb98e2 100644 --- a/app/service_invite/rest.py +++ b/app/service_invite/rest.py @@ -91,13 +91,15 @@ def _create_service_invite(invited_user, invite_link_host): # This is for the login.gov service invite on the # "Set Up Your Profile" path. redis_key = f"service-invite-{invited_user.email_address}" - redis_store.set( + redis_store.raw_set( redis_key, json.dumps(data), ex=3600 * 24, ) # TODO REMOVE DEBUG print(hilite(f"Save this data {data} with this redis_key {redis_key}")) + did_we_save_it = redis_store.raw_get(redis_key) + print(hilite(f"Did we save the data successfully? {did_we_save_it}")) # END DEBUG send_notification_to_queue(saved_notification, queue=QueueNames.NOTIFY) From c02f32a263ec22b19af2ae5eec2aa286cca9195a Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Fri, 19 Apr 2024 10:33:26 -0700 Subject: [PATCH 2/2] use raw_set and raw_get, fix tests --- tests/app/service_invite/test_service_invite_rest.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/app/service_invite/test_service_invite_rest.py b/tests/app/service_invite/test_service_invite_rest.py index f36ad4ce5..e736a3042 100644 --- a/tests/app/service_invite/test_service_invite_rest.py +++ b/tests/app/service_invite/test_service_invite_rest.py @@ -31,6 +31,9 @@ def test_create_invited_user( extra_args, expected_start_of_invite_url, ): + mocker.patch("app.service_invite.rest.redis_store.raw_set") + mocker.patch("app.service_invite.rest.redis_store.raw_get") + mocked = mocker.patch("app.celery.provider_tasks.deliver_email.apply_async") email_address = "invited_user@service.gov.uk" invite_from = sample_service.users[0] @@ -92,6 +95,9 @@ def test_create_invited_user( def test_create_invited_user_without_auth_type( admin_request, sample_service, mocker, invitation_email_template ): + + mocker.patch("app.service_invite.rest.redis_store.raw_set") + mocker.patch("app.service_invite.rest.redis_store.raw_get") mocker.patch("app.celery.provider_tasks.deliver_email.apply_async") email_address = "invited_user@service.gov.uk" invite_from = sample_service.users[0] @@ -213,6 +219,9 @@ def test_resend_expired_invite( invitation_email_template, mocker, ): + + mocker.patch("app.service_invite.rest.redis_store.raw_set") + mocker.patch("app.service_invite.rest.redis_store.raw_get") url = f"/service/{sample_expired_user.service_id}/invite/{sample_expired_user.id}/resend" mock_send = mocker.patch("app.service_invite.rest.send_notification_to_queue") mock_persist = mocker.patch("app.service_invite.rest.persist_notification")