From a61d8c5358e645122ea8c1242bd98c5016666310 Mon Sep 17 00:00:00 2001 From: Trent Palmer Date: Sun, 11 Apr 2021 15:16:41 -0700 Subject: [PATCH] extend audio/tests/test_edit_episode_view.py --- audio/tests/test_edit_episode_view.py | 28 +++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/audio/tests/test_edit_episode_view.py b/audio/tests/test_edit_episode_view.py index baac14a..0d17cf4 100644 --- a/audio/tests/test_edit_episode_view.py +++ b/audio/tests/test_edit_episode_view.py @@ -4,7 +4,7 @@ from audio.tests.test_views import set_up from audio.models import Episode -class TestEditEpisodeView(TestCase): +class TestEditEpisodeViewTestCase(TestCase): def setUp(self): set_up() @@ -31,7 +31,10 @@ class TestEditEpisodeView(TestCase): self.assertEquals(episode_ab.episode_number, 2) self.assertEquals(episode_ab.description, "An essay about the human quality of bees.") self.assertEquals(episode_ab.image_attribution, "USGS Bee Inventory and Monitoring Lab") - self.assertEquals(episode_ab.original_image_url, "https://www.flickr.com/photos/usgsbiml/14589580124/") + self.assertEquals( + episode_ab.original_image_url, + "https://www.flickr.com/photos/usgsbiml/14589580124/" + ) self.assertEquals(episode_ab.image_license, 1) self.assertEquals(episode_ab.image_license_jurisdiction, "in the United States") @@ -40,6 +43,27 @@ class TestEditEpisodeView(TestCase): self.client.login(username='user_b', password='password_user_b') kw_args = {'pk': episode_a.pk, 'title_slug': episode_a.slug} response = self.client.post(reverse('audio:edit_episode', kwargs=kw_args)) + self.assertTemplateUsed(response, 'base_form.html') self.assertEquals(response.status_code, 200) episode_ab = Episode.objects.get(title="Mark Twain The Bee") self.assertEquals(episode_ab.author, '') + + def test_edit_episode_view_no_login(self): + episode_a = Episode.objects.get(title="Mark Twain The Bee") + kw_args = {'pk': episode_a.pk, 'title_slug': episode_a.slug} + response = self.client.post(reverse('audio:edit_episode', kwargs=kw_args), { + 'title': episode_a.title, + 'author': "Twain Mark", + 'pub_date': episode_a.pub_date, + 'episode_number': 2, + 'description': "An essay about the human quality of bees.", + 'image_title': "Stenotritus pubescens", + 'image_attribution': "USGS Bee Inventory and Monitoring Lab", + 'original_image_url': "https://www.flickr.com/photos/usgsbiml/14589580124/", + 'image_license': 1, + 'image_license_jurisdiction': "in the United States", + }, follow=True) + self.assertTemplateUsed(response, 'audio/index.html') + self.assertEquals(response.status_code, 200) + episode_ab = Episode.objects.get(title="Mark Twain The Bee") + self.assertEquals(episode_ab.author, "")