def test_post(self): video = VideoFactory(user=self.user, buckets=[BucketFactory(user=self.user)]) data = {"id": video.youtube_id} response = self.client.post(reverse( "bucket-video-viewed-api", kwargs={"bucket": video.buckets.first().pk}), data=data) self.assertEqual(response.status_code, 200) video.refresh_from_db() self.assertEqual(video.viewed, True) self.assertEqual(video.buckets.all()[0].last_watched_video, video.ordering_key)
def test_post(self): video = VideoFactory(user=self.user, subscription=SubscriptionFactory(user=self.user)) data = {"id": video.youtube_id} response = self.client.post(reverse( "subscription-video-viewed-api", kwargs={"subscription": video.subscription_id}), data=data) self.assertEqual(response.status_code, 200) video.refresh_from_db() video.subscription.refresh_from_db() self.assertEqual(video.viewed, True) self.assertEqual(video.subscription.last_watched_video, video.ordering_key)