def test_user_role_student_get_anonymized_shortname(self): testassignment = mommy.make_recipe( 'devilry.apps.core.assignment_activeperiod_start', anonymizationmode=core_models.Assignment. ANONYMIZATIONMODE_SEMI_ANONYMOUS) testgroup = mommy.make('core.AssignmentGroup', parentnode=testassignment) testuser = mommy.make(settings.AUTH_USER_MODEL) test_studentuser = mommy.make(settings.AUTH_USER_MODEL, fullname='Test Student', shortname='*****@*****.**') mommy.make( 'core.Candidate', assignment_group=testgroup, relatedstudent__user=test_studentuser, relatedstudent__automatic_anonymous_id='Some anonymous name', relatedstudent__period=testassignment.parentnode) group_user_lookup = GroupUserLookup( assignment=testassignment, group=testgroup, requestuser=testuser, requestuser_devilryrole=self.viewrole) self.assertEqual( group_user_lookup.get_plaintext_short_name_from_user( user=test_studentuser, user_role='student'), 'Some anonymous name')
def test_user_role_examiner_get_unanonymized_shortname(self): testassignment = mommy.make_recipe('devilry.apps.core.assignment_activeperiod_start') testgroup = mommy.make('core.AssignmentGroup', parentnode=testassignment) testuser = mommy.make(settings.AUTH_USER_MODEL) test_examineruser = mommy.make(settings.AUTH_USER_MODEL, fullname='Test Examiner', shortname='*****@*****.**') mommy.make('core.RelatedExaminer', user=test_examineruser, period=testassignment.parentnode) group_user_lookup = GroupUserLookup(assignment=testassignment, group=testgroup, requestuser=testuser, requestuser_devilryrole=self.viewrole) self.assertEqual( group_user_lookup.get_plaintext_short_name_from_user(user=test_examineruser, user_role='examiner'), '*****@*****.**')
def test_user_role_examiner_get_anonymized_shortname(self): testassignment = mommy.make_recipe('devilry.apps.core.assignment_activeperiod_start', anonymizationmode=core_models.Assignment.ANONYMIZATIONMODE_SEMI_ANONYMOUS) testgroup = mommy.make('core.AssignmentGroup', parentnode=testassignment) testuser = mommy.make(settings.AUTH_USER_MODEL) test_examineruser = mommy.make(settings.AUTH_USER_MODEL, fullname='Test Examiner', shortname='*****@*****.**') mommy.make('core.RelatedExaminer', user=test_examineruser, period=testassignment.parentnode, automatic_anonymous_id='Some anonymous name') group_user_lookup = GroupUserLookup(assignment=testassignment, group=testgroup, requestuser=testuser, requestuser_devilryrole=self.viewrole) self.assertEqual( group_user_lookup.get_plaintext_short_name_from_user(user=test_examineruser, user_role='examiner'), 'Some anonymous name')
def test_user_role_examiner_get_unanonymized_shortname(self): testassignment = mommy.make_recipe( 'devilry.apps.core.assignment_activeperiod_start') testgroup = mommy.make('core.AssignmentGroup', parentnode=testassignment) testuser = mommy.make(settings.AUTH_USER_MODEL) test_examineruser = mommy.make(settings.AUTH_USER_MODEL, fullname='Test Examiner', shortname='*****@*****.**') mommy.make('core.RelatedExaminer', user=test_examineruser, period=testassignment.parentnode) group_user_lookup = GroupUserLookup( assignment=testassignment, group=testgroup, requestuser=testuser, requestuser_devilryrole=self.viewrole) self.assertEqual( group_user_lookup.get_plaintext_short_name_from_user( user=test_examineruser, user_role='examiner'), '*****@*****.**')