def test_model_method(self): vid = VideoFactory(youtube_id="123") with self.assertRaises(AttributeError): vid.title with self.assertRaises(AttributeError): vid.description vid.add_titles() self.assertEqual(vid.title, "henlo") self.assertEqual(vid.description, "bluh bluh")
def test_get(self): subscription = SubscriptionFactory(user=self.user) video = VideoFactory(user=self.user, subscription=subscription) video = video.add_titles() response = self.client.get( reverse("subscription-video-api", kwargs={"subscription": subscription.pk})) self.assertEqual(response.status_code, 200) data = json.loads(response.content) self.assertEqual( data, { "next": "{}?after={}".format( reverse("subscription-video-api", kwargs={"subscription": subscription.pk}), video.ordering_key), "videos": [{ "id": video.youtube_id, "title": video.title, "description": video.description, "published": datetime_to_js_iso(video.published_at), "html_snippet": video.html_snippet, "ordering_key": video.ordering_key, }], })