forked from mirrors/bookwyrm
Adds test for logged out view of group
This commit is contained in:
parent
ec7c1e75fe
commit
8a3be920c6
1 changed files with 15 additions and 0 deletions
|
@ -1,6 +1,8 @@
|
|||
""" test for app action functionality """
|
||||
from unittest.mock import patch
|
||||
|
||||
from django.contrib.auth.models import AnonymousUser
|
||||
from django.http import Http404
|
||||
from django.template.response import TemplateResponse
|
||||
from django.test import TestCase
|
||||
from django.test.client import RequestFactory
|
||||
|
@ -43,6 +45,8 @@ class GroupViews(TestCase):
|
|||
self.membership = models.GroupMember.objects.create(
|
||||
group=self.testgroup, user=self.local_user
|
||||
)
|
||||
self.anonymous_user = AnonymousUser
|
||||
self.anonymous_user.is_authenticated = False
|
||||
|
||||
models.SiteSettings.objects.create()
|
||||
|
||||
|
@ -56,6 +60,17 @@ class GroupViews(TestCase):
|
|||
validate_html(result.render())
|
||||
self.assertEqual(result.status_code, 200)
|
||||
|
||||
def test_group_get_anonymous(self, _):
|
||||
"""there are so many views, this just makes sure it LOADS"""
|
||||
self.testgroup.privacy = "followers"
|
||||
self.testgroup.save()
|
||||
|
||||
view = views.Group.as_view()
|
||||
request = self.factory.get("")
|
||||
request.user = self.anonymous_user
|
||||
with self.assertRaises(Http404):
|
||||
view(request, group_id=self.testgroup.id)
|
||||
|
||||
def test_usergroups_get(self, _):
|
||||
"""there are so many views, this just makes sure it LOADS"""
|
||||
view = views.UserGroups.as_view()
|
||||
|
|
Loading…
Reference in a new issue