kopia lustrzana https://github.com/wagtail/wagtail
Fix modeladmin tests for EmailUser
rodzic
da5b5d4161
commit
d3b3d4e203
|
@ -1,5 +1,4 @@
|
||||||
from django import VERSION as DJANGO_VERSION
|
from django import VERSION as DJANGO_VERSION
|
||||||
from django.contrib.auth import get_user_model
|
|
||||||
from django.contrib.auth.models import Group, Permission
|
from django.contrib.auth.models import Group, Permission
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
|
|
||||||
|
@ -278,10 +277,10 @@ class TestChooseParentViewForNonSuperuser(TestCase, WagtailTestUtils):
|
||||||
permission_type='add'
|
permission_type='add'
|
||||||
)
|
)
|
||||||
|
|
||||||
user = get_user_model().objects._create_user(username='test2', email='test2@email.com', password='password', is_staff=True, is_superuser=False)
|
user = self.create_user(username='test2', password='password')
|
||||||
user.groups.add(business_editors)
|
user.groups.add(business_editors)
|
||||||
# Login
|
# Login
|
||||||
self.client.login(username='test2', password='password')
|
self.login(username='test2', password='password')
|
||||||
|
|
||||||
def test_simple(self):
|
def test_simple(self):
|
||||||
response = self.client.get('/admin/tests/businesschild/choose_parent/')
|
response = self.client.get('/admin/tests/businesschild/choose_parent/')
|
||||||
|
@ -291,40 +290,32 @@ class TestChooseParentViewForNonSuperuser(TestCase, WagtailTestUtils):
|
||||||
self.assertNotContains(response, 'Private Business Index')
|
self.assertNotContains(response, 'Private Business Index')
|
||||||
|
|
||||||
|
|
||||||
class TestEditorAccess(TestCase):
|
class TestEditorAccess(TestCase, WagtailTestUtils):
|
||||||
fixtures = ['test_specific.json']
|
fixtures = ['test_specific.json']
|
||||||
expected_status_code = 403
|
expected_status_code = 403
|
||||||
|
|
||||||
def login(self):
|
def setUp(self):
|
||||||
# Create a user
|
# Create a user
|
||||||
user = get_user_model().objects._create_user(username='test2', email='test2@email.com', password='password', is_staff=True, is_superuser=False)
|
user = self.create_user(username='test2', password='password')
|
||||||
user.groups.add(Group.objects.get(pk=2))
|
user.groups.add(Group.objects.get(pk=2))
|
||||||
# Login
|
# Login
|
||||||
self.client.login(username='test2', password='password')
|
self.login(username='test2', password='password')
|
||||||
return user
|
|
||||||
|
|
||||||
def setUp(self):
|
|
||||||
self.login()
|
|
||||||
|
|
||||||
def test_delete_permitted(self):
|
def test_delete_permitted(self):
|
||||||
response = self.client.get('/admin/tests/eventpage/delete/4/')
|
response = self.client.get('/admin/tests/eventpage/delete/4/')
|
||||||
self.assertEqual(response.status_code, self.expected_status_code)
|
self.assertEqual(response.status_code, self.expected_status_code)
|
||||||
|
|
||||||
|
|
||||||
class TestModeratorAccess(TestCase):
|
class TestModeratorAccess(TestCase, WagtailTestUtils):
|
||||||
fixtures = ['test_specific.json']
|
fixtures = ['test_specific.json']
|
||||||
expected_status_code = 302
|
expected_status_code = 302
|
||||||
|
|
||||||
def login(self):
|
def setUp(self):
|
||||||
# Create a user
|
# Create a user
|
||||||
user = get_user_model().objects._create_user(username='test3', email='test3@email.com', password='password', is_staff=True, is_superuser=False)
|
user = self.create_user(username='test3', password='password')
|
||||||
user.groups.add(Group.objects.get(pk=1))
|
user.groups.add(Group.objects.get(pk=1))
|
||||||
# Login
|
# Login
|
||||||
self.client.login(username='test2', password='password')
|
self.login(username='test3', password='password')
|
||||||
return user
|
|
||||||
|
|
||||||
def setUp(self):
|
|
||||||
self.login()
|
|
||||||
|
|
||||||
def test_delete_permitted(self):
|
def test_delete_permitted(self):
|
||||||
response = self.client.get('/admin/tests/eventpage/delete/4/')
|
response = self.client.get('/admin/tests/eventpage/delete/4/')
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
|
||||||
from django.contrib.auth import get_user_model
|
|
||||||
from django.contrib.auth.models import Group
|
from django.contrib.auth.models import Group
|
||||||
from django.core import checks
|
from django.core import checks
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
|
@ -514,22 +513,19 @@ class TestDeleteViewModelReprPrimary(TestCase, WagtailTestUtils):
|
||||||
self.assertEqual(response.status_code, 302)
|
self.assertEqual(response.status_code, 302)
|
||||||
|
|
||||||
|
|
||||||
class TestEditorAccess(TestCase):
|
class TestEditorAccess(TestCase, WagtailTestUtils):
|
||||||
fixtures = ['modeladmintest_test.json']
|
fixtures = ['modeladmintest_test.json']
|
||||||
expected_status_code = 403
|
expected_status_code = 403
|
||||||
|
|
||||||
def login(self):
|
def setUp(self):
|
||||||
# Create a user
|
# Create a user
|
||||||
user = get_user_model().objects._create_user(username='test2', email='test2@email.com', password='password', is_staff=True, is_superuser=False)
|
user = self.create_user(username='test2', password='password')
|
||||||
user.groups.add(Group.objects.get(pk=2))
|
user.groups.add(Group.objects.get(pk=2))
|
||||||
# Login
|
# Login
|
||||||
self.client.login(username='test2', password='password')
|
self.login(username='test2', password='password')
|
||||||
|
|
||||||
return user
|
return user
|
||||||
|
|
||||||
def setUp(self):
|
|
||||||
self.login()
|
|
||||||
|
|
||||||
def test_index_permitted(self):
|
def test_index_permitted(self):
|
||||||
response = self.client.get('/admin/modeladmintest/book/')
|
response = self.client.get('/admin/modeladmintest/book/')
|
||||||
self.assertEqual(response.status_code, self.expected_status_code)
|
self.assertEqual(response.status_code, self.expected_status_code)
|
||||||
|
|
Ładowanie…
Reference in New Issue