本文整理汇总了Python中allianceauth.tests.auth_utils.AuthUtils.disconnect_signals方法的典型用法代码示例。如果您正苦于以下问题:Python AuthUtils.disconnect_signals方法的具体用法?Python AuthUtils.disconnect_signals怎么用?Python AuthUtils.disconnect_signals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类allianceauth.tests.auth_utils.AuthUtils
的用法示例。
在下文中一共展示了AuthUtils.disconnect_signals方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_m2m_changed_group_permissions
# 需要导入模块: from allianceauth.tests.auth_utils import AuthUtils [as 别名]
# 或者: from allianceauth.tests.auth_utils.AuthUtils import disconnect_signals [as 别名]
def test_m2m_changed_group_permissions(self, services_hook, transaction):
from django.contrib.contenttypes.models import ContentType
svc = mock.Mock()
svc.validate_user.return_value = None
svc.access_perm = 'auth.access_testsvc'
services_hook.get_services.return_value = [svc]
# Overload transaction.on_commit so everything happens synchronously
transaction.on_commit = lambda fn: fn()
test_group = Group.objects.create(name="Test group")
AuthUtils.disconnect_signals()
self.member.groups.add(test_group)
AuthUtils.connect_signals()
ct = ContentType.objects.get(app_label='auth', model='permission')
perm = Permission.objects.create(name="Test perm", codename="access_testsvc", content_type=ct)
test_group.permissions.add(perm)
# Act, should trigger m2m change
test_group.permissions.remove(perm)
# Assert
self.assertTrue(services_hook.get_services.called)
self.assertTrue(svc.validate_user.called)
args, kwargs = svc.validate_user.call_args
self.assertEqual(self.member, args[0])
示例2: setUp
# 需要导入模块: from allianceauth.tests.auth_utils import AuthUtils [as 别名]
# 或者: from allianceauth.tests.auth_utils.AuthUtils import disconnect_signals [as 别名]
def setUp(self):
self.member = AuthUtils.create_member('auth_member')
AuthUtils.add_main_character(self.member, 'test character', '1234', '2345', 'test corp', 'testc')
self.member.email = '[email protected]'
self.member.save()
self.none_user = AuthUtils.create_user('none_user', disconnect_signals=True)
self.none_user2 = AuthUtils.create_user('none_user2', disconnect_signals=True)
self.none_user3 = AuthUtils.create_user('none_user3', disconnect_signals=True)
self.no_perm_user = AuthUtils.create_user('no_perm_user', disconnect_signals=True)
AuthUtils.disconnect_signals()
self.no_perm_group = Group.objects.create(name="No Permission Group")
self.test_group = Group.objects.create(name="Test group")
self.test_group.user_set.add(self.none_user)
self.test_group.user_set.add(self.none_user2)
self.test_group.user_set.add(self.none_user3)
self.permission = Permission.objects.get_by_natural_key(codename='audit_permissions',
app_label='permissions_tool',
model='permissionstool')
self.test_group.permissions.add(self.permission)
self.member.user_permissions.add(self.permission)
AuthUtils.connect_signals()
示例3: setUpTestData
# 需要导入模块: from allianceauth.tests.auth_utils import AuthUtils [as 别名]
# 或者: from allianceauth.tests.auth_utils.AuthUtils import disconnect_signals [as 别名]
def setUpTestData(cls):
cls.main_character = EveCharacter.objects.create(
character_id=1,
character_name='Main Character',
corporation_id=1,
corporation_name='Corp',
corporation_ticker='CORP',
)
cls.alt_character = EveCharacter.objects.create(
character_id=2,
character_name='Alt Character',
corporation_id=1,
corporation_name='Corp',
corporation_ticker='CORP',
)
cls.unclaimed_character = EveCharacter.objects.create(
character_id=3,
character_name='Unclaimed Character',
corporation_id=1,
corporation_name='Corp',
corporation_ticker='CORP',
)
cls.user = AuthUtils.create_user('test_user', disconnect_signals=True)
cls.old_user = AuthUtils.create_user('old_user', disconnect_signals=True)
AuthUtils.disconnect_signals()
CharacterOwnership.objects.create(user=cls.user, character=cls.main_character, owner_hash='1')
CharacterOwnership.objects.create(user=cls.user, character=cls.alt_character, owner_hash='2')
UserProfile.objects.update_or_create(user=cls.user, defaults={'main_character': cls.main_character})
AuthUtils.connect_signals()
示例4: test_registered
# 需要导入模块: from allianceauth.tests.auth_utils import AuthUtils [as 别名]
# 或者: from allianceauth.tests.auth_utils.AuthUtils import disconnect_signals [as 别名]
def test_registered(self):
self.assertFalse(self.member.registered)
AuthUtils.disconnect_signals()
character = EveCharacter.objects.create(character_id='2', character_name='other test character', corporation_id='2', corporation_name='test corp', corporation_ticker='TEST')
CharacterOwnership.objects.create(character=character, user=self.user, owner_hash='b')
self.assertTrue(self.member.registered)
AuthUtils.connect_signals()
示例5: test_main_character
# 需要导入模块: from allianceauth.tests.auth_utils import AuthUtils [as 别名]
# 或者: from allianceauth.tests.auth_utils.AuthUtils import disconnect_signals [as 别名]
def test_main_character(self):
AuthUtils.disconnect_signals()
# test when member.character is None
self.assertIsNone(self.member.main_character)
# test when member.character is not None but also not a main
character = EveCharacter.objects.create(character_id='2', character_name='other test character', corporation_id='2', corporation_name='test corp', corporation_ticker='TEST')
CharacterOwnership.objects.create(character=character, user=self.user, owner_hash='b')
self.member.refresh_from_db()
self.assertNotEqual(self.member.main_character, self.member.character)
self.assertEquals(self.member.main_character, self.user.profile.main_character)
# test when is main
old_main = self.user.profile.main_character
self.user.profile.main_character = character
self.user.profile.save()
self.member.refresh_from_db()
self.assertEqual(self.member.main_character, self.member.character)
self.assertEqual(self.user.profile.main_character, self.member.main_character)
# transaction won't roll this back
self.user.profile.main_character = old_main
self.user.profile.save()
AuthUtils.connect_signals()
示例6: test_mains
# 需要导入模块: from allianceauth.tests.auth_utils import AuthUtils [as 别名]
# 或者: from allianceauth.tests.auth_utils.AuthUtils import disconnect_signals [as 别名]
def test_mains(self):
# test when is a main
member = CorpMember.objects.create(corpstats=self.corpstats, character_id='1', character_name='test character')
self.assertIn(member, self.corpstats.mains)
self.assertEqual(self.corpstats.main_count, 1)
# test when is an alt
old_main = self.user.profile.main_character
character = EveCharacter.objects.create(character_name='other character', character_id=10, corporation_name='test corp', corporation_id='2', corporation_ticker='TEST')
AuthUtils.disconnect_signals()
co = CharacterOwnership.objects.create(character=character, user=self.user, owner_hash='b')
self.user.profile.main_character = character
self.user.profile.save()
AuthUtils.connect_signals()
self.assertNotIn(member, self.corpstats.mains)
self.assertEqual(self.corpstats.main_count, 0)
# test when no ownership
co.delete()
self.assertNotIn(member, self.corpstats.mains)
self.assertEqual(self.corpstats.main_count, 0)
# transaction won't roll this back
AuthUtils.disconnect_signals()
self.user.profile.main_character = old_main
self.user.profile.save()
AuthUtils.connect_signals()
示例7: test_user_count
# 需要导入模块: from allianceauth.tests.auth_utils import AuthUtils [as 别名]
# 或者: from allianceauth.tests.auth_utils.AuthUtils import disconnect_signals [as 别名]
def test_user_count(self):
AuthUtils.disconnect_signals()
co = CharacterOwnership.objects.create(character=self.character, user=self.user, owner_hash='a')
AuthUtils.connect_signals()
CorpMember.objects.create(corpstats=self.corpstats, character_id='4', character_name='test character')
self.assertEqual(self.corpstats.user_count, 1)
co.delete()
self.assertEqual(self.corpstats.user_count, 0)
示例8: test_unregistered_members
# 需要导入模块: from allianceauth.tests.auth_utils import AuthUtils [as 别名]
# 或者: from allianceauth.tests.auth_utils.AuthUtils import disconnect_signals [as 别名]
def test_unregistered_members(self):
member = CorpMember.objects.create(corpstats=self.corpstats, character_id='4', character_name='test character')
self.corpstats.refresh_from_db()
self.assertIn(member, self.corpstats.unregistered_members)
self.assertEqual(self.corpstats.unregistered_member_count, 1)
AuthUtils.disconnect_signals()
CharacterOwnership.objects.create(character=self.character, user=self.user, owner_hash='a')
AuthUtils.connect_signals()
self.assertNotIn(member, self.corpstats.unregistered_members)
self.assertEqual(self.corpstats.unregistered_member_count, 0)
示例9: test_update_groups
# 需要导入模块: from allianceauth.tests.auth_utils import AuthUtils [as 别名]
# 或者: from allianceauth.tests.auth_utils.AuthUtils import disconnect_signals [as 别名]
def test_update_groups(self):
# Check member has Member group updated
with mock.patch(MODULE_PATH + '.tasks.DiscordOAuthManager') as manager:
service = self.service()
member = User.objects.get(username=self.member)
AuthUtils.disconnect_signals()
service.update_groups(member)
self.assertTrue(manager.update_groups.called)
args, kwargs = manager.update_groups.call_args
user_id, groups = args
self.assertIn(DEFAULT_AUTH_GROUP, groups)
self.assertEqual(user_id, member.discord.uid)
# Check none user does not have groups updated
with mock.patch(MODULE_PATH + '.tasks.DiscordOAuthManager') as manager:
service = self.service()
none_user = User.objects.get(username=self.none_user)
service.update_groups(none_user)
self.assertFalse(manager.update_groups.called)