From bf62862b9fe0d2bfc7f90e200ebf82393ffc1787 Mon Sep 17 00:00:00 2001 From: Feanil Patel Date: Tue, 12 Aug 2025 16:03:48 -0400 Subject: [PATCH] test: Fix notifacitons test for new DRF version. DRF was swallowing an underlying error string and providing its own which was being checked for here. See https://github.com/encode/django-rest-framework/pull/8051 for details. The new version fixes that underlying issue and so the test failed. Rather than checking for the exact string of the 404 which is not relevant, we now just verify that the error code associated with the request matches the HTTP response. This should make the test more resilient to future text changes in the underlying Django function `get_object_or_404` --- openedx/core/djangoapps/notifications/tests/test_views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openedx/core/djangoapps/notifications/tests/test_views.py b/openedx/core/djangoapps/notifications/tests/test_views.py index 745b690b5c..de02141745 100644 --- a/openedx/core/djangoapps/notifications/tests/test_views.py +++ b/openedx/core/djangoapps/notifications/tests/test_views.py @@ -443,7 +443,7 @@ class NotificationReadAPIViewTestCase(APITestCase): response = self.client.patch(self.url, data) self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND) - self.assertEqual(response.data["detail"], 'Not found.') + self.assertEqual(response.data["detail"].code, 'not_found') def test_mark_notification_read_with_app_name_and_notification_id(self): # Create a PATCH request to mark notification as read for existing app e.g 'discussion' and notification_id: 2