From 73b19832aa0573b9ebdbf71c869593fcf02de97c Mon Sep 17 00:00:00 2001 From: Awais Qureshi Date: Thu, 28 Aug 2025 00:34:36 +0500 Subject: [PATCH] fix: ensure _get_user returns saved user (with id) (#37290) Django 5.2 tightened model handling: unsaved User objects (no primary key) no longer pass through in some checks. --- openedx/features/content_type_gating/tests/test_access.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/openedx/features/content_type_gating/tests/test_access.py b/openedx/features/content_type_gating/tests/test_access.py index c42a530e3c..3e3dae1298 100644 --- a/openedx/features/content_type_gating/tests/test_access.py +++ b/openedx/features/content_type_gating/tests/test_access.py @@ -1190,9 +1190,10 @@ class TestContentTypeGatingService(ModuleStoreTestCase): self.user, blocks_dict['not_graded_1'], course['course'].id ) is None - @patch.object(ContentTypeGatingService, '_get_user', return_value=UserFactory.build()) - def test_check_children_for_content_type_gating_paywall(self, mocked_user): # pylint: disable=unused-argument + @patch.object(ContentTypeGatingService, "_get_user") + def test_check_children_for_content_type_gating_paywall(self, mocked_get_user): ''' Verify that the method returns a content type gate when appropriate ''' + mocked_get_user.return_value = UserFactory.create() # saved user object with id course = self._create_course() blocks_dict = course['blocks'] CourseEnrollmentFactory.create(