Adds test for logged out view of group

This commit is contained in:
Mouse Reeve 2021-12-28 14:27:11 -08:00
parent ec7c1e75fe
commit 8a3be920c6

View file

@ -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()