Patch site settings so this can pass

This commit is contained in:
Chad Nelson 2021-01-27 22:13:35 -05:00
parent 9c2813545c
commit 4274bf0508

View file

@ -1,7 +1,6 @@
''' testing import ''' ''' testing import '''
from unittest.mock import patch from unittest.mock import patch
from django.test import RequestFactory, TestCase from django.test import RequestFactory, TestCase
import responses import responses
@ -12,6 +11,9 @@ from bookwyrm.settings import DOMAIN
class RssFeedView(TestCase): class RssFeedView(TestCase):
''' rss feed behaves as expected ''' ''' rss feed behaves as expected '''
def setUp(self): def setUp(self):
self.site = models.SiteSettings.objects.create()
self.user = models.User.objects.create_user( self.user = models.User.objects.create_user(
'rss_user', 'rss@test.rss', 'password', local=True) 'rss_user', 'rss@test.rss', 'password', local=True)
@ -39,7 +41,12 @@ class RssFeedView(TestCase):
def test_rss_feed(self): def test_rss_feed(self):
view = rss_feed.RssFeed() view = rss_feed.RssFeed()
request = self.factory.get('/user/rss_user/rss') request = self.factory.get('/user/rss_user/rss')
result = view(request, username=self.user.username) with patch("bookwyrm.models.SiteSettings.objects.get") as site:
site.return_value = self.site
result = view(request, username=self.user.username)
self.assertEqual(result.status_code, 200) self.assertEqual(result.status_code, 200)
self.assertEqual(False, True)
self.assertIn(b"Status updates from rss_user", result.content)
self.assertIn( b"a sickening sense", result.content)
self.assertIn(b"Example Edition", result.content)