当前位置: 首页>>代码示例>>Python>>正文


Python AuthUtils.connect_signals方法代码示例

本文整理汇总了Python中allianceauth.tests.auth_utils.AuthUtils.connect_signals方法的典型用法代码示例。如果您正苦于以下问题:Python AuthUtils.connect_signals方法的具体用法?Python AuthUtils.connect_signals怎么用?Python AuthUtils.connect_signals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在allianceauth.tests.auth_utils.AuthUtils的用法示例。


在下文中一共展示了AuthUtils.connect_signals方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setUp

# 需要导入模块: from allianceauth.tests.auth_utils import AuthUtils [as 别名]
# 或者: from allianceauth.tests.auth_utils.AuthUtils import connect_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()
开发者ID:Kaezon,项目名称:allianceauth,代码行数:29,代码来源:tests.py

示例2: setUpTestData

# 需要导入模块: from allianceauth.tests.auth_utils import AuthUtils [as 别名]
# 或者: from allianceauth.tests.auth_utils.AuthUtils import connect_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()
开发者ID:Kaezon,项目名称:allianceauth,代码行数:31,代码来源:tests.py

示例3: test_m2m_changed_group_permissions

# 需要导入模块: from allianceauth.tests.auth_utils import AuthUtils [as 别名]
# 或者: from allianceauth.tests.auth_utils.AuthUtils import connect_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])
开发者ID:Kaezon,项目名称:allianceauth,代码行数:31,代码来源:test_signals.py

示例4: test_registered

# 需要导入模块: from allianceauth.tests.auth_utils import AuthUtils [as 别名]
# 或者: from allianceauth.tests.auth_utils.AuthUtils import connect_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()
开发者ID:Kaezon,项目名称:allianceauth,代码行数:9,代码来源:tests.py

示例5: test_main_character

# 需要导入模块: from allianceauth.tests.auth_utils import AuthUtils [as 别名]
# 或者: from allianceauth.tests.auth_utils.AuthUtils import connect_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()
开发者ID:Kaezon,项目名称:allianceauth,代码行数:27,代码来源:tests.py

示例6: test_mains

# 需要导入模块: from allianceauth.tests.auth_utils import AuthUtils [as 别名]
# 或者: from allianceauth.tests.auth_utils.AuthUtils import connect_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()
开发者ID:Kaezon,项目名称:allianceauth,代码行数:29,代码来源:tests.py

示例7: test_user_count

# 需要导入模块: from allianceauth.tests.auth_utils import AuthUtils [as 别名]
# 或者: from allianceauth.tests.auth_utils.AuthUtils import connect_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)
开发者ID:Kaezon,项目名称:allianceauth,代码行数:10,代码来源:tests.py

示例8: test_unregistered_members

# 需要导入模块: from allianceauth.tests.auth_utils import AuthUtils [as 别名]
# 或者: from allianceauth.tests.auth_utils.AuthUtils import connect_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)
开发者ID:Kaezon,项目名称:allianceauth,代码行数:13,代码来源:tests.py


注:本文中的allianceauth.tests.auth_utils.AuthUtils.connect_signals方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。