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.
This commit is contained in:
Awais Qureshi
2025-08-28 00:34:36 +05:00
committed by GitHub
parent ec83b2aa64
commit 73b19832aa

View File

@@ -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(