From 72ceb18fdd33918fc17eb9deb61fc425cff207b7 Mon Sep 17 00:00:00 2001 From: Trent Palmer Date: Thu, 22 Apr 2021 20:19:47 -0700 Subject: [PATCH] update audio/tests/test_new_episode_view.py add function test_new_episode_view_wrong_user() --- audio/tests/test_new_episode_view.py | 30 ++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/audio/tests/test_new_episode_view.py b/audio/tests/test_new_episode_view.py index cd02f8f..ac4a423 100644 --- a/audio/tests/test_new_episode_view.py +++ b/audio/tests/test_new_episode_view.py @@ -11,6 +11,36 @@ class TestNewEpisodeViewTestCase(TestCase): def setUp(self): set_up() + def test_new_episode_view_wrong_user(self): + feed_a = Feed.objects.get(title="Short Stories Mark Twain") + self.client.login(username='user_a', password='password_user_a') + kw_args = {'feed_pk': feed_a.pk, 'feed_title_slug': feed_a.slug} + pub_date = str(date.today()) + with ( + open('bicycle.jpg', 'rb') as image_f, + open('Mark Twain Taming The Bicycle.mp3', 'rb') as mp3_f + ): + response = self.client.post(reverse('audio:new_episode', kwargs=kw_args), { + 'title': "Mark Twain Taming The Bicycle", + 'author': "Mark Twain", + 'pub_date': pub_date, + 'episode_number': 3, + 'description': 'learn how to ride a bicycle', + 'mp3': mp3_f, + 'image_title': 'A Penny Farthing', + 'image_attribution': 'Agnieszka KwiecieĊ„', + 'image_attribution_url': 'https://commons.wikimedia.org/wiki/User:Nova', + 'original_image_url': 'https://commons.wikimedia.org/wiki/File:Ordinary_bicycle01.jpg', + 'image_license': 1, + 'image_license_jurisdiction': 'in the USA', + 'image': image_f, + }, follow=True) + self.assertEquals(response.status_code, 200) + self.assertFalse(Episode.objects.filter( + title="Mark Twain Taming The Bicycle").exists()) + self.assertEquals(response.request['PATH_INFO'], '/') + self.assertTemplateUsed(response, 'audio/index.html') + def test_new_episode_view_no_data(self): feed_a = Feed.objects.get(title="Short Stories Mark Twain") self.client.login(username='user_b', password='password_user_b')