File tree Expand file tree Collapse file tree 2 files changed +11
-4
lines changed
manage_breast_screening/notifications Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -54,7 +54,7 @@ def test_create_message_status_with_valid_request():
5454 queue_instance .add .assert_called_once_with (json .dumps (body ))
5555
5656
57- def test_create_message_status_with_invalid_request ():
57+ def test_create_message_status_with_invalid_request (mock_insights_logger ):
5858 req = RequestFactory ().post (
5959 "/notifications/message-status/create" ,
6060 {"some" : "data" },
@@ -68,3 +68,7 @@ def test_create_message_status_with_invalid_request():
6868
6969 assert response .status_code == expected_response .status_code
7070 assert response .text == expected_response .text
71+
72+ mock_insights_logger .assert_called_once_with (
73+ "Request validation failed: Signature does not match"
74+ )
Original file line number Diff line number Diff line change 1- import logging
2-
31from django .contrib .auth .decorators import login_not_required
42from django .http import JsonResponse
53from django .views .decorators .csrf import csrf_exempt
86from manage_breast_screening .core .decorators import (
97 basic_auth_exempt ,
108)
9+ from manage_breast_screening .notifications .services .application_insights_logging import (
10+ ApplicationInsightsLogging ,
11+ )
1112from manage_breast_screening .notifications .services .queue import Queue
1213from manage_breast_screening .notifications .validators .request_validator import (
1314 RequestValidator ,
@@ -22,7 +23,9 @@ def create_message_status(request):
2223 valid , message = RequestValidator (request ).valid ()
2324
2425 if not valid :
25- logging .error ("Request validation failed: %s" , message )
26+ ApplicationInsightsLogging ().exception (
27+ (f"Request validation failed: { message } " )
28+ )
2629 return JsonResponse ({"error" : {"message" : message }}, status = 400 )
2730
2831 Queue .MessageStatusUpdates ().add (request .body .decode ("ASCII" ))
You can’t perform that action at this time.
0 commit comments