def test_user_has_shared_true_if_shared(self): self.content.share(self.profile) serializer = ContentSerializer( context={"request": Mock(user=self.user)}) self.assertTrue(serializer.get_user_has_shared(self.content))
def test_user_has_shared_false_if_anonymous_user(self): serializer = ContentSerializer( context={"request": Mock(user=AnonymousUser())}) self.assertFalse(serializer.get_user_has_shared(None))
def test_user_has_shared_false_if_not_shared(self): serializer = ContentSerializer( context={"request": Mock(user=self.user)}) self.assertFalse(serializer.get_user_has_shared(self.content))
def test_user_has_shared_false_if_no_request(self): serializer = ContentSerializer() self.assertFalse(serializer.get_user_has_shared(None))
def test_user_has_shared_true_if_shared(self): self.content.share(self.profile) serializer = ContentSerializer(context={"request": Mock(user=self.user)}) self.assertTrue(serializer.get_user_has_shared(self.content))
def test_user_has_shared_false_if_not_shared(self): serializer = ContentSerializer(context={"request": Mock(user=self.user)}) self.assertFalse(serializer.get_user_has_shared(self.content))
def test_user_has_shared_false_if_anonymous_user(self): serializer = ContentSerializer(context={"request": Mock(user=AnonymousUser())}) self.assertFalse(serializer.get_user_has_shared(None))
def test_user_has_shared_false_if_no_request(self): serializer = ContentSerializer() self.assertFalse(serializer.get_user_has_shared(None))