def test_user_is_author_true_if_author(self): serializer = ContentSerializer( context={"request": Mock(user=self.user)}) self.assertTrue(serializer.get_user_is_author(self.user_content))
def test_user_is_author_false_if_not_authenticated(self): serializer = ContentSerializer( context={"request": Mock(user=AnonymousUser())}) self.assertFalse(serializer.get_user_is_author(None))
def test_user_is_author_false_if_not_author(self): serializer = ContentSerializer( context={"request": Mock(user=self.user)}) self.assertFalse(serializer.get_user_is_author(self.content))
def test_user_is_author_false_if_no_request(self): serializer = ContentSerializer() self.assertFalse(serializer.get_user_is_author(None))
def test_user_is_author_true_if_author(self): serializer = ContentSerializer(context={"request": Mock(user=self.user)}) self.assertTrue(serializer.get_user_is_author(self.user_content))
def test_user_is_author_false_if_not_author(self): serializer = ContentSerializer(context={"request": Mock(user=self.user)}) self.assertFalse(serializer.get_user_is_author(self.content))
def test_user_is_author_false_if_not_authenticated(self): serializer = ContentSerializer(context={"request": Mock(user=AnonymousUser())}) self.assertFalse(serializer.get_user_is_author(None))