add PATH_INFO test to audio/tests

This commit is contained in:
Trent Palmer 2021-04-18 15:13:58 -07:00
parent 3d110192e8
commit b6ec41c095
7 changed files with 50 additions and 0 deletions

View File

@ -20,6 +20,10 @@ class TestConfirmDeleteEpisodeViewTestCase(TestCase):
self.assertTemplateUsed(response, 'audio/index.html') self.assertTemplateUsed(response, 'audio/index.html')
qs = Episode.objects.filter(title="Mark Twain The Bee") qs = Episode.objects.filter(title="Mark Twain The Bee")
self.assertEquals(len(qs), 0) self.assertEquals(len(qs), 0)
self.assertEquals(
response.request['PATH_INFO'],
f'/feed/{episode_a.feed.pk}/{episode_a.feed.slug}'
)
def test_confirm_delete_episode_view_no_login(self): def test_confirm_delete_episode_view_no_login(self):
episode_a = Episode.objects.get(title="Mark Twain The Bee") episode_a = Episode.objects.get(title="Mark Twain The Bee")
@ -31,3 +35,4 @@ class TestConfirmDeleteEpisodeViewTestCase(TestCase):
self.assertTemplateUsed(response, 'audio/index.html') self.assertTemplateUsed(response, 'audio/index.html')
qs = Episode.objects.filter(title="Mark Twain The Bee") qs = Episode.objects.filter(title="Mark Twain The Bee")
self.assertEquals(len(qs), 1) self.assertEquals(len(qs), 1)
self.assertEquals(response.request['PATH_INFO'], '/')

View File

@ -24,6 +24,7 @@ class TestConfirmDeleteFeedViewTestCase(TestCase):
self.assertEquals(len(qs), 0) self.assertEquals(len(qs), 0)
qs = Episode.objects.filter(title="Mark Twain The Bee") qs = Episode.objects.filter(title="Mark Twain The Bee")
self.assertEquals(len(qs), 0) self.assertEquals(len(qs), 0)
self.assertEquals(response.request['PATH_INFO'], '/feeds/')
def test_confirm_delete_feed_view_no_login(self): def test_confirm_delete_feed_view_no_login(self):
feed_a = Feed.objects.get(title="Short Stories Mark Twain") feed_a = Feed.objects.get(title="Short Stories Mark Twain")
@ -39,3 +40,4 @@ class TestConfirmDeleteFeedViewTestCase(TestCase):
self.assertEquals(len(qs), 1) self.assertEquals(len(qs), 1)
qs = Episode.objects.filter(title="Mark Twain The Bee") qs = Episode.objects.filter(title="Mark Twain The Bee")
self.assertEquals(len(qs), 1) self.assertEquals(len(qs), 1)
self.assertEquals(response.request['PATH_INFO'], '/')

View File

@ -37,6 +37,10 @@ class TestEditEpisodeViewTestCase(TestCase):
) )
self.assertEquals(episode_ab.image_license, 1) self.assertEquals(episode_ab.image_license, 1)
self.assertEquals(episode_ab.image_license_jurisdiction, "in the United States") self.assertEquals(episode_ab.image_license_jurisdiction, "in the United States")
self.assertEquals(
response.request['PATH_INFO'],
f'/edit-episode/{episode_ab.pk}/{episode_ab.slug}'
)
def test_edit_episode_view_no_data(self): def test_edit_episode_view_no_data(self):
episode_a = Episode.objects.get(title="Mark Twain The Bee") episode_a = Episode.objects.get(title="Mark Twain The Bee")
@ -47,6 +51,10 @@ class TestEditEpisodeViewTestCase(TestCase):
self.assertEquals(response.status_code, 200) self.assertEquals(response.status_code, 200)
episode_ab = Episode.objects.get(title="Mark Twain The Bee") episode_ab = Episode.objects.get(title="Mark Twain The Bee")
self.assertEquals(episode_ab.author, '') self.assertEquals(episode_ab.author, '')
self.assertEquals(
response.request['PATH_INFO'],
f'/edit-episode/{episode_ab.pk}/{episode_ab.slug}'
)
def test_edit_episode_view_no_login(self): def test_edit_episode_view_no_login(self):
episode_a = Episode.objects.get(title="Mark Twain The Bee") episode_a = Episode.objects.get(title="Mark Twain The Bee")
@ -67,3 +75,4 @@ class TestEditEpisodeViewTestCase(TestCase):
self.assertEquals(response.status_code, 200) self.assertEquals(response.status_code, 200)
episode_ab = Episode.objects.get(title="Mark Twain The Bee") episode_ab = Episode.objects.get(title="Mark Twain The Bee")
self.assertEquals(episode_ab.author, "") self.assertEquals(episode_ab.author, "")
self.assertEquals(response.request['PATH_INFO'], '/')

View File

@ -62,6 +62,10 @@ class TestEditFeedViewTestCase(TestCase):
self.assertEquals(feed_a.license_url, "https://en.wikipedia.org/wiki/Public_domain") self.assertEquals(feed_a.license_url, "https://en.wikipedia.org/wiki/Public_domain")
self.assertEquals(feed_a.license_name, 'Public Domain') self.assertEquals(feed_a.license_name, 'Public Domain')
self.assertEquals(feed_a.get_itpc_rss, f'itpc://{settings.DOMAIN_NAME}/rss/{feed_a.slug}.xml') self.assertEquals(feed_a.get_itpc_rss, f'itpc://{settings.DOMAIN_NAME}/rss/{feed_a.slug}.xml')
self.assertEquals(
response.request['PATH_INFO'],
f'/edit-feed/{feed_a.pk}/{feed_a.slug}'
)
def test_edit_feed_view_no_data(self): def test_edit_feed_view_no_data(self):
feed_c = Feed.objects.get(title="Short Stories Mark Twain") feed_c = Feed.objects.get(title="Short Stories Mark Twain")
@ -95,6 +99,10 @@ class TestEditFeedViewTestCase(TestCase):
self.assertEquals(feed_a.license_url, "https://en.wikipedia.org/wiki/Public_domain") self.assertEquals(feed_a.license_url, "https://en.wikipedia.org/wiki/Public_domain")
self.assertEquals(feed_a.license_name, 'Public Domain') self.assertEquals(feed_a.license_name, 'Public Domain')
self.assertEquals(feed_a.get_itpc_rss, f'itpc://{settings.DOMAIN_NAME}/rss/{feed_a.slug}.xml') self.assertEquals(feed_a.get_itpc_rss, f'itpc://{settings.DOMAIN_NAME}/rss/{feed_a.slug}.xml')
self.assertEquals(
response.request['PATH_INFO'],
f'/edit-feed/{feed_a.pk}/{feed_a.slug}'
)
def test_edit_feed_view(self): def test_edit_feed_view(self):
feed_c = Feed.objects.get(title="Short Stories Mark Twain") feed_c = Feed.objects.get(title="Short Stories Mark Twain")
@ -149,3 +157,7 @@ class TestEditFeedViewTestCase(TestCase):
self.assertEquals(feed_a.license_url, "https://en.wikipedia.org/wiki/Public_domain") self.assertEquals(feed_a.license_url, "https://en.wikipedia.org/wiki/Public_domain")
self.assertEquals(feed_a.license_name, 'Public Domain') self.assertEquals(feed_a.license_name, 'Public Domain')
self.assertEquals(feed_a.get_itpc_rss, f'itpc://{settings.DOMAIN_NAME}/rss/{feed_a.slug}.xml') self.assertEquals(feed_a.get_itpc_rss, f'itpc://{settings.DOMAIN_NAME}/rss/{feed_a.slug}.xml')
self.assertEquals(
response.request['PATH_INFO'],
f'/edit-feed/{feed_a.pk}/{feed_a.slug}'
)

View File

@ -20,6 +20,10 @@ class TestNewEpisodeViewTestCase(TestCase):
self.assertEquals(response.status_code, 200) self.assertEquals(response.status_code, 200)
qs = Episode.objects.filter(title="Mark Twain Taming The Bicycle") qs = Episode.objects.filter(title="Mark Twain Taming The Bicycle")
self.assertEquals(len(qs), 0) self.assertEquals(len(qs), 0)
self.assertEquals(
response.request['PATH_INFO'],
f'/new-episode/{feed_a.pk}/{feed_a.slug}'
)
def test_new_episode_view_no_login(self): def test_new_episode_view_no_login(self):
feed_a = Feed.objects.get(title="Short Stories Mark Twain") feed_a = Feed.objects.get(title="Short Stories Mark Twain")
@ -48,6 +52,7 @@ class TestNewEpisodeViewTestCase(TestCase):
self.assertEquals(response.status_code, 200) self.assertEquals(response.status_code, 200)
qs = Episode.objects.filter(title="Mark Twain Taming The Bicycle") qs = Episode.objects.filter(title="Mark Twain Taming The Bicycle")
self.assertEquals(len(qs), 0) self.assertEquals(len(qs), 0)
self.assertEquals(response.request['PATH_INFO'], '/')
def test_new_episode_view(self): def test_new_episode_view(self):
feed_a = Feed.objects.get(title="Short Stories Mark Twain") feed_a = Feed.objects.get(title="Short Stories Mark Twain")
@ -99,3 +104,7 @@ class TestNewEpisodeViewTestCase(TestCase):
) )
self.assertEquals(episode_a.user, user_b) self.assertEquals(episode_a.user, user_b)
self.assertEquals(episode_a.feed, feed_a) self.assertEquals(episode_a.feed, feed_a)
self.assertEquals(
response.request['PATH_INFO'],
f'/new-episode/{feed_a.pk}/{feed_a.slug}'
)

View File

@ -32,6 +32,7 @@ class TestNewFeedViewTestCase(TestCase):
self.assertTemplateUsed(response, 'base_form.html') self.assertTemplateUsed(response, 'base_form.html')
qs = Feed.objects.filter(title="Short Stories Mark Twain") qs = Feed.objects.filter(title="Short Stories Mark Twain")
self.assertEquals(len(qs), 0) self.assertEquals(len(qs), 0)
self.assertEquals(response.request['PATH_INFO'], '/new-feed/')
def test_new_feed_view_no_login(self): def test_new_feed_view_no_login(self):
with open('bicycle.jpg', 'rb') as image_f: with open('bicycle.jpg', 'rb') as image_f:
@ -60,6 +61,7 @@ class TestNewFeedViewTestCase(TestCase):
self.assertTemplateUsed(response, 'audio/index.html') self.assertTemplateUsed(response, 'audio/index.html')
qs = Feed.objects.filter(title="Short Stories Mark Twain") qs = Feed.objects.filter(title="Short Stories Mark Twain")
self.assertEquals(len(qs), 0) self.assertEquals(len(qs), 0)
self.assertEquals(response.request['PATH_INFO'], '/')
def test_new_feed_view(self): def test_new_feed_view(self):
self.client.login(username='user_b', password='password_user_b') self.client.login(username='user_b', password='password_user_b')
@ -112,3 +114,4 @@ class TestNewFeedViewTestCase(TestCase):
self.assertEquals(feed_a.license_url, "https://en.wikipedia.org/wiki/Public_domain") self.assertEquals(feed_a.license_url, "https://en.wikipedia.org/wiki/Public_domain")
self.assertEquals(feed_a.license_name, 'Public Domain') self.assertEquals(feed_a.license_name, 'Public Domain')
self.assertEquals(feed_a.get_itpc_rss, f'itpc://{settings.DOMAIN_NAME}/rss/{feed_a.slug}.xml') self.assertEquals(feed_a.get_itpc_rss, f'itpc://{settings.DOMAIN_NAME}/rss/{feed_a.slug}.xml')
self.assertEquals(response.request['PATH_INFO'], '/new-feed/')

View File

@ -53,6 +53,7 @@ class TestViewsTestCase(TestCase):
response = self.client.get(reverse('audio:home')) response = self.client.get(reverse('audio:home'))
self.assertEquals(response.status_code, 200) self.assertEquals(response.status_code, 200)
self.assertTemplateUsed(response, 'audio/index.html') self.assertTemplateUsed(response, 'audio/index.html')
self.assertEquals(response.request['PATH_INFO'], '/')
def test_feed_view(self): def test_feed_view(self):
feed_a = Feed.objects.get(title="Short Stories Mark Twain") feed_a = Feed.objects.get(title="Short Stories Mark Twain")
@ -60,6 +61,10 @@ class TestViewsTestCase(TestCase):
response = self.client.get(reverse('audio:feed', kwargs=kw_args)) response = self.client.get(reverse('audio:feed', kwargs=kw_args))
self.assertEquals(response.status_code, 200) self.assertEquals(response.status_code, 200)
self.assertTemplateUsed(response, 'audio/index.html') self.assertTemplateUsed(response, 'audio/index.html')
self.assertEquals(
response.request['PATH_INFO'],
f'/feed/{feed_a.pk}/{feed_a.slug}'
)
def test_episode_view(self): def test_episode_view(self):
episode_a = Episode.objects.get(title='Mark Twain The Bee') episode_a = Episode.objects.get(title='Mark Twain The Bee')
@ -67,8 +72,13 @@ class TestViewsTestCase(TestCase):
response = self.client.get(reverse('audio:episode', kwargs=kw_args)) response = self.client.get(reverse('audio:episode', kwargs=kw_args))
self.assertEquals(response.status_code, 200) self.assertEquals(response.status_code, 200)
self.assertTemplateUsed(response, 'audio/index.html') self.assertTemplateUsed(response, 'audio/index.html')
self.assertEquals(
response.request['PATH_INFO'],
f'/episode/{episode_a.pk}/{episode_a.slug}'
)
def test_feeds_view(self): def test_feeds_view(self):
response = self.client.get(reverse('audio:feeds')) response = self.client.get(reverse('audio:feeds'))
self.assertEquals(response.status_code, 200) self.assertEquals(response.status_code, 200)
self.assertTemplateUsed(response, 'audio/feeds.html') self.assertTemplateUsed(response, 'audio/feeds.html')
self.assertEquals(response.request['PATH_INFO'], '/feeds/')