mirror of
https://gitlab.com/allianceauth/allianceauth.git
synced 2025-07-14 23:10:15 +02:00
Update tests.
This commit is contained in:
parent
0f0f9b6062
commit
7c1d1074f9
@ -11,7 +11,7 @@ from allianceauth.eveonline.models import (
|
||||
EveCharacter, EveCorporationInfo, EveAllianceInfo
|
||||
)
|
||||
|
||||
from ..admin import HasLeaderFilter, GroupAdmin, Group
|
||||
from ..admin import HasLeaderFilter, GroupAdmin, Group, AuthGroup
|
||||
from . import get_admin_change_view_url
|
||||
|
||||
if 'allianceauth.eveonline.autogroups' in settings.INSTALLED_APPS:
|
||||
@ -38,7 +38,8 @@ class TestGroupAdmin(TestCase):
|
||||
super().setUpClass()
|
||||
|
||||
# group 1 - has leader
|
||||
cls.group_1 = Group.objects.create(name='Group 1')
|
||||
cls.group_1 = Group.objects.create(name='Group 1')
|
||||
AuthGroup.objects.create(group=cls.group_1)
|
||||
cls.group_1.authgroup.description = 'Default Group'
|
||||
cls.group_1.authgroup.internal = False
|
||||
cls.group_1.authgroup.hidden = False
|
||||
@ -46,12 +47,14 @@ class TestGroupAdmin(TestCase):
|
||||
|
||||
# group 2 - no leader
|
||||
cls.group_2 = Group.objects.create(name='Group 2')
|
||||
AuthGroup.objects.create(group=cls.group_2)
|
||||
cls.group_2.authgroup.description = 'Internal Group'
|
||||
cls.group_2.authgroup.internal = True
|
||||
cls.group_2.authgroup.save()
|
||||
|
||||
# group 3 - has leader
|
||||
cls.group_3 = Group.objects.create(name='Group 3')
|
||||
AuthGroup.objects.create(group=cls.group_3)
|
||||
cls.group_3.authgroup.description = 'Hidden Group'
|
||||
cls.group_3.authgroup.internal = False
|
||||
cls.group_3.authgroup.hidden = True
|
||||
@ -59,6 +62,7 @@ class TestGroupAdmin(TestCase):
|
||||
|
||||
# group 4 - no leader
|
||||
cls.group_4 = Group.objects.create(name='Group 4')
|
||||
AuthGroup.objects.create(group=cls.group_4)
|
||||
cls.group_4.authgroup.description = 'Open Group'
|
||||
cls.group_4.authgroup.internal = False
|
||||
cls.group_4.authgroup.hidden = False
|
||||
@ -67,6 +71,7 @@ class TestGroupAdmin(TestCase):
|
||||
|
||||
# group 5 - no leader
|
||||
cls.group_5 = Group.objects.create(name='Group 5')
|
||||
AuthGroup.objects.create(group=cls.group_5)
|
||||
cls.group_5.authgroup.description = 'Public Group'
|
||||
cls.group_5.authgroup.internal = False
|
||||
cls.group_5.authgroup.hidden = False
|
||||
@ -75,6 +80,7 @@ class TestGroupAdmin(TestCase):
|
||||
|
||||
# group 6 - no leader
|
||||
cls.group_6 = Group.objects.create(name='Group 6')
|
||||
AuthGroup.objects.create(group=cls.group_6)
|
||||
cls.group_6.authgroup.description = 'Mixed Group'
|
||||
cls.group_6.authgroup.internal = False
|
||||
cls.group_6.authgroup.hidden = True
|
||||
|
@ -7,7 +7,7 @@ from django.urls import reverse
|
||||
from allianceauth.eveonline.models import EveCorporationInfo, EveAllianceInfo
|
||||
from allianceauth.tests.auth_utils import AuthUtils
|
||||
|
||||
from ..models import GroupRequest
|
||||
from ..models import GroupRequest, AuthGroup
|
||||
from ..managers import GroupManager
|
||||
|
||||
|
||||
@ -29,8 +29,11 @@ class GroupManagementVisibilityTestCase(TestCase):
|
||||
corporation_id='2', corporation_name='test corp', corporation_ticker='TEST', alliance=cls.alliance, member_count=1
|
||||
)
|
||||
cls.group1 = Group.objects.create(name='group1')
|
||||
AuthGroup.objects.create(group=cls.group1)
|
||||
cls.group2 = Group.objects.create(name='group2')
|
||||
AuthGroup.objects.create(group=cls.group2)
|
||||
cls.group3 = Group.objects.create(name='group3')
|
||||
AuthGroup.objects.create(group=cls.group3)
|
||||
|
||||
def setUp(self):
|
||||
self.user.refresh_from_db()
|
||||
@ -77,7 +80,8 @@ class TestGroupManager(TestCase):
|
||||
super().setUpClass()
|
||||
|
||||
# group 1
|
||||
cls.group_default = Group.objects.create(name='default')
|
||||
cls.group_default = Group.objects.create(name='default')
|
||||
AuthGroup.objects.create(group=cls.group_default)
|
||||
cls.group_default.authgroup.description = 'Default Group'
|
||||
cls.group_default.authgroup.internal = False
|
||||
cls.group_default.authgroup.hidden = False
|
||||
@ -85,12 +89,14 @@ class TestGroupManager(TestCase):
|
||||
|
||||
# group 2
|
||||
cls.group_internal = Group.objects.create(name='internal')
|
||||
AuthGroup.objects.create(group=cls.group_internal)
|
||||
cls.group_internal.authgroup.description = 'Internal Group'
|
||||
cls.group_internal.authgroup.internal = True
|
||||
cls.group_internal.authgroup.save()
|
||||
|
||||
# group 3
|
||||
cls.group_hidden = Group.objects.create(name='hidden')
|
||||
AuthGroup.objects.create(group=cls.group_hidden)
|
||||
cls.group_hidden.authgroup.description = 'Hidden Group'
|
||||
cls.group_hidden.authgroup.internal = False
|
||||
cls.group_hidden.authgroup.hidden = True
|
||||
@ -98,6 +104,7 @@ class TestGroupManager(TestCase):
|
||||
|
||||
# group 4
|
||||
cls.group_open = Group.objects.create(name='open')
|
||||
AuthGroup.objects.create(group=cls.group_open)
|
||||
cls.group_open.authgroup.description = 'Open Group'
|
||||
cls.group_open.authgroup.internal = False
|
||||
cls.group_open.authgroup.hidden = False
|
||||
@ -106,6 +113,7 @@ class TestGroupManager(TestCase):
|
||||
|
||||
# group 5
|
||||
cls.group_public_1 = Group.objects.create(name='public 1')
|
||||
AuthGroup.objects.create(group=cls.group_public_1)
|
||||
cls.group_public_1.authgroup.description = 'Public Group 1'
|
||||
cls.group_public_1.authgroup.internal = False
|
||||
cls.group_public_1.authgroup.hidden = False
|
||||
@ -114,6 +122,7 @@ class TestGroupManager(TestCase):
|
||||
|
||||
# group 6
|
||||
cls.group_public_2 = Group.objects.create(name='public 2')
|
||||
AuthGroup.objects.create(group=cls.group_public_2)
|
||||
cls.group_public_2.authgroup.description = 'Public Group 2'
|
||||
cls.group_public_2.authgroup.internal = False
|
||||
cls.group_public_2.authgroup.hidden = True
|
||||
@ -123,6 +132,7 @@ class TestGroupManager(TestCase):
|
||||
|
||||
# group 7
|
||||
cls.group_default_member = Group.objects.create(name='default members')
|
||||
AuthGroup.objects.create(group=cls.group_default_member)
|
||||
cls.group_default_member.authgroup.description = \
|
||||
'Default Group for members only'
|
||||
cls.group_default_member.authgroup.internal = False
|
||||
@ -338,7 +348,9 @@ class TestPendingRequestsCountForUser(TestCase):
|
||||
|
||||
def setUp(self) -> None:
|
||||
self.group_1 = Group.objects.create(name="Group 1")
|
||||
AuthGroup.objects.create(group=self.group_1)
|
||||
self.group_2 = Group.objects.create(name="Group 2")
|
||||
AuthGroup.objects.create(group=self.group_2)
|
||||
self.user_leader_1 = AuthUtils.create_member('Clark Kent')
|
||||
self.group_1.authgroup.group_leaders.add(self.user_leader_1)
|
||||
self.user_leader_2 = AuthUtils.create_member('Peter Parker')
|
||||
|
@ -8,7 +8,7 @@ from allianceauth.eveonline.models import (
|
||||
EveCorporationInfo, EveAllianceInfo, EveCharacter
|
||||
)
|
||||
|
||||
from ..models import GroupRequest, RequestLog
|
||||
from ..models import GroupRequest, RequestLog, AuthGroup
|
||||
|
||||
|
||||
def create_testdata():
|
||||
@ -20,7 +20,8 @@ def create_testdata():
|
||||
EveAllianceInfo.objects.all().delete()
|
||||
|
||||
# group 1
|
||||
group = Group.objects.create(name='Superheros')
|
||||
group = Group.objects.create(name='Superheros')
|
||||
AuthGroup.objects.create(group=group)
|
||||
group.authgroup.description = 'Default Group'
|
||||
group.authgroup.internal = False
|
||||
group.authgroup.hidden = False
|
||||
|
@ -5,6 +5,8 @@ from allianceauth.eveonline.models import EveCorporationInfo
|
||||
from allianceauth.eveonline.autogroups.models import AutogroupsConfig
|
||||
from allianceauth.tests.auth_utils import AuthUtils
|
||||
|
||||
from ..models import AuthGroup
|
||||
|
||||
|
||||
class TestCheckGroupsOnStateChange(TestCase):
|
||||
|
||||
@ -39,14 +41,17 @@ class TestCheckGroupsOnStateChange(TestCase):
|
||||
and remains member of normal group and auto group
|
||||
"""
|
||||
# setup
|
||||
state_group = Group.objects.create(name='state_group')
|
||||
state_group = Group.objects.create(name='state_group')
|
||||
AuthGroup.objects.create(group=state_group)
|
||||
state_group.authgroup.states.add(self.test_state_1)
|
||||
state_group.authgroup.internal = False
|
||||
state_group.save()
|
||||
normal_group = Group.objects.create(name='normal_group')
|
||||
AuthGroup.objects.create(group=normal_group)
|
||||
normal_group.authgroup.internal = False
|
||||
normal_group.save()
|
||||
internal_group = Group.objects.create(name='internal_group')
|
||||
internal_group = Group.objects.create(name='internal_group')
|
||||
AuthGroup.objects.create(group=internal_group)
|
||||
autogroup_config = AutogroupsConfig.objects.create(corp_groups=True)
|
||||
autogroup_config.states.add(self.test_state_1)
|
||||
autogroup_config.states.add(self.guest_state)
|
||||
@ -79,7 +84,8 @@ class TestCheckGroupsOnStateChange(TestCase):
|
||||
then user remains member of that group
|
||||
"""
|
||||
# setup
|
||||
state_group = Group.objects.create(name='state_group')
|
||||
state_group = Group.objects.create(name='state_group')
|
||||
AuthGroup.objects.create(group=state_group)
|
||||
state_group.authgroup.states.add(self.test_state_1)
|
||||
state_group.authgroup.states.add(self.test_state_2)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user