Ejemplo n.º 1
0
    def test_user_moderator_is_True(self):
        bob = self._create_user(can_moderate=True)
        self._send_auth_comment(bob)

        # Fetch the comment, serialize it and check user_moderator field.
        xtdcomment = XtdComment.objects.get(pk=1)
        context = {"request": {"user": bob}}
        ser = ReadCommentSerializer(xtdcomment, context=context)
        self.assertTrue(ser.data['user_moderator'])
Ejemplo n.º 2
0
 def test_submit_date_when_use_tz_is_true(self):
     self.create_comment(submit_date_is_aware=True)
     qs = XtdComment.objects.all()
     ser = ReadCommentSerializer(qs, context={"request": None}, many=True)
     self.assertEqual(ser.data[0]['submit_date'],
                      'Jan. 10, 2021, 11:15 a.m.')
Ejemplo n.º 3
0
 def test_setting_COMMENTS_XTD_API_GET_USER_AVATAR_works(self):
     qs = XtdComment.objects.all()
     ser = ReadCommentSerializer(qs, context={"request": None}, many=True)
     self.assertEqual(ser.data[0]['user_avatar'], '/fake/avatar/joe')
     self.assertEqual(ser.data[1]['user_avatar'], '/fake/avatar/alice')