add audio/tests/test_episode_model.py, audio/tests/test_feed_model.py

This commit is contained in:
Trent Palmer 2021-04-21 16:40:57 -07:00
parent 88790e4080
commit 9fe3b45a00
2 changed files with 42 additions and 0 deletions

View File

@ -0,0 +1,24 @@
from django.test import TestCase
from audio.models import Feed, Episode
from django.contrib.auth.models import User
from uuid import UUID
from datetime import datetime, timedelta
class EpisodeModelTestCase(TestCase):
def setUp(self):
user_a = User.objects.create(username='user_a')
feed_a = Feed.objects.create(user=user_a, title='Civil War')
p_date = datetime.today() - timedelta(days=8)
Episode.objects.create(
title='Chapter I', feed=feed_a, user=user_a,
pub_date=p_date
)
def test_episode(self):
qs = Episode.objects.all()
self.assertEquals(len(qs), 1)
episode_a = Episode.objects.get(title='Chapter I')
self.assertTrue(isinstance(episode_a.pk, UUID))
self.assertEquals(str(episode_a), episode_a.title)

View File

@ -0,0 +1,18 @@
from django.test import TestCase
from audio.models import Feed
from django.contrib.auth.models import User
from uuid import UUID
class FeedModelTestCase(TestCase):
def setUp(self):
user_a = User.objects.create(username='user_a')
Feed.objects.create(user=user_a, title='Civil War')
def test_feed(self):
qs = Feed.objects.all()
self.assertEquals(len(qs), 1)
feed_a = Feed.objects.get(title='Civil War')
self.assertTrue(isinstance(feed_a.pk, UUID))
self.assertEquals(str(feed_a), feed_a.title)