def test_examiner_group_comment_item_value_fully_anonymous(self):
     testassignment = mommy.make_recipe(
         'devilry.apps.core.assignment_activeperiod_start',
         anonymizationmode=core_models.Assignment.
         ANONYMIZATIONMODE_FULLY_ANONYMOUS)
     testgroup = mommy.make('core.AssignmentGroup',
                            parentnode=testassignment)
     examiner = mommy.make(
         'core.Examiner',
         assignmentgroup=testgroup,
         relatedexaminer__user__fullname='Test User',
         relatedexaminer__user__shortname='*****@*****.**')
     comment = mommy.make('devilry_group.GroupComment',
                          user=examiner.relatedexaminer.user,
                          user_role='examiner',
                          feedback_set__group=testgroup)
     selector = htmls.S(
         listbuilder.StudentGroupCommentItemValue(
             value=comment,
             devilry_viewrole='student',
             user_obj=examiner,
             assignment=testassignment).render())
     self.assertFalse(
         selector.exists('.devilry-user-verbose-inline-fullname'))
     self.assertTrue(
         selector.exists('.devilry-core-examiner-anonymous-name'))
 def test_student_comment_devilryrole_examiner_assignment_fully_anonymized(self):
     self.__model_setup(anonymizationmode=core_models.Assignment.ANONYMIZATIONMODE_FULLY_ANONYMOUS)
     selector = htmls.S(listbuilder.StudentGroupCommentItemValue(
         requestuser=mommy.make(settings.AUTH_USER_MODEL),
         value=self.comment,
         devilry_viewrole=None,
         user_obj=self.candidate,
         assignment=self.testassignment,
         group_user_lookup=self.group_user_lookup
     ).render())
     self.assertFalse(selector.exists('.devilry-user-verbose-inline-fullname'))
     self.assertTrue(selector.exists('.devilry-core-candidate-anonymous-name'))
     self.assertNotIn('Test User([email protected])', selector.html)
     self.assertIn('Anonymous student', selector.one('.devilry-core-candidate-anonymous-name').alltext_normalized)
 def test_student_comment_devilryrole_examiner_is_not_anonymized(self):
     self.__model_setup()
     selector = htmls.S(listbuilder.StudentGroupCommentItemValue(
         requestuser=mommy.make(settings.AUTH_USER_MODEL),
         value=self.comment,
         devilry_viewrole=None,
         user_obj=self.candidate,
         assignment=self.testassignment,
         group_user_lookup=self.group_user_lookup
     ).render())
     self.assertTrue(selector.exists('.devilry-user-verbose-inline-both'))
     self.assertFalse(selector.exists('.devilry-core-candidate-anonymous-name'))
     self.assertIn('Test User([email protected])',
                   selector.one('.devilry-user-verbose-inline-both').alltext_normalized)
 def test_student_group_comment_item_value_non_anonymous(self):
     testassignment = mommy.make_recipe(
         'devilry.apps.core.assignment_activeperiod_start')
     testgroup = mommy.make('core.AssignmentGroup',
                            parentnode=testassignment)
     candidate = mommy.make(
         'core.Candidate',
         assignment_group=testgroup,
         relatedstudent__user__fullname='Test User',
         relatedstudent__user__shortname='*****@*****.**')
     comment = mommy.make('devilry_group.GroupComment',
                          user=candidate.relatedstudent.user,
                          user_role='student',
                          feedback_set__group=testgroup)
     selector = htmls.S(
         listbuilder.StudentGroupCommentItemValue(
             value=comment,
             devilry_viewrole='examiner',
             user_obj=candidate,
             assignment=testassignment).render())
     self.assertTrue(
         selector.exists('.devilry-user-verbose-inline-fullname'))