11"""
22Tests for LTI Names and Role Provisioning Service views.
33"""
4- from mock import patch , PropertyMock
4+ from mock import Mock , patch , PropertyMock
55from Cryptodome .PublicKey import RSA
66from jwkest .jwk import RSAKey
77from rest_framework .test import APITransactionTestCase
@@ -226,12 +226,12 @@ def test_token_with_incorrect_scope(self):
226226 response = self .client .get (self .context_membership_endpoint )
227227 self .assertEqual (response .status_code , 403 )
228228
229- @patch ('lti_consumer.plugin.views.expose_pii_fields ' , return_value = False )
229+ @patch ('lti_consumer.plugin.views.get_lti_pii_sharing_state_for_course ' , Mock ( return_value = False ) )
230230 @patch (
231231 'lti_consumer.plugin.views.compat.get_course_members' ,
232- side_effect = patch_get_memberships ()
232+ Mock ( side_effect = patch_get_memberships ()),
233233 )
234- def test_token_with_correct_scope (self , get_course_members_patcher , expose_pii_fields_patcher ): # pylint: disable=unused-argument
234+ def test_token_with_correct_scope (self ):
235235 """
236236 Test if context membership returns correct response when token has correct scope
237237 """
@@ -240,14 +240,14 @@ def test_token_with_correct_scope(self, get_course_members_patcher, expose_pii_f
240240 self .assertEqual (response .status_code , 200 )
241241 self .assertEqual (response ['content-type' ], 'application/vnd.ims.lti-nrps.v2.membershipcontainer+json' )
242242
243- @patch ('lti_consumer.plugin.views.expose_pii_fields ' , return_value = False )
243+ @patch ('lti_consumer.plugin.views.get_lti_pii_sharing_state_for_course ' , return_value = False )
244244 @patch (
245245 'lti_consumer.plugin.views.compat.get_course_members' ,
246- side_effect = patch_get_memberships ({
246+ Mock ( side_effect = patch_get_memberships ({
247247 'student' : 4
248- })
248+ })),
249249 )
250- def test_get_without_pii (self , get_course_members_patcher , expose_pii_fields_patcher ): # pylint: disable=unused-argument
250+ def test_get_without_pii (self , expose_pii_fields_patcher ):
251251 """
252252 Test context membership endpoint response structure with PII not exposed.
253253 """
@@ -267,14 +267,14 @@ def test_get_without_pii(self, get_course_members_patcher, expose_pii_fields_pat
267267 self .assertNotIn ('email' , member_fields )
268268 self .assertNotIn ('name' , member_fields )
269269
270- @patch ('lti_consumer.plugin.views.expose_pii_fields ' , return_value = True )
270+ @patch ('lti_consumer.plugin.views.get_lti_pii_sharing_state_for_course ' , return_value = True )
271271 @patch (
272272 'lti_consumer.plugin.views.compat.get_course_members' ,
273- side_effect = patch_get_memberships ({
273+ Mock ( side_effect = patch_get_memberships ({
274274 'student' : 4
275- })
275+ })),
276276 )
277- def test_get_with_pii (self , get_course_members_patcher , expose_pii_fields_patcher ): # pylint: disable=unused-argument
277+ def test_get_with_pii (self , expose_pii_fields_patcher ):
278278 """
279279 Test context membership endpoint response structure with PII exposed.
280280 """
@@ -295,14 +295,14 @@ def test_get_with_pii(self, get_course_members_patcher, expose_pii_fields_patche
295295 self .assertIn ('email' , member_fields )
296296 self .assertIn ('name' , member_fields )
297297
298- @patch ('lti_consumer.plugin.views.expose_pii_fields ' , return_value = False )
298+ @patch ('lti_consumer.plugin.views.get_lti_pii_sharing_state_for_course ' , Mock ( return_value = False ) )
299299 @patch (
300300 'lti_consumer.plugin.views.compat.get_course_members' ,
301- side_effect = patch_get_memberships ({
301+ Mock ( side_effect = patch_get_memberships ({
302302 'exception' : True
303- })
303+ })),
304304 )
305- def test_enrollment_limit_gate (self , get_course_members_patcher , expose_pii_fields_patcher ): # pylint: disable=unused-argument
305+ def test_enrollment_limit_gate (self ):
306306 """
307307 Test if number of enrolled user is larger than the limit, api returns 404 response.
308308 """
0 commit comments