Пример #1
0
    def test_models_sync_inconsistencies(self):
        from groups_manager import settings
        settings.GROUPS_MANAGER = deepcopy(GROUPS_MANAGER_MOCK)

        # change sync between group creation and deletion
        settings.GROUPS_MANAGER['AUTH_MODELS_SYNC'] = False
        w = testproject_models.WorkGroup(name='New workgroup')
        w.save()
        self.assertIsNone(w.django_group)
        settings.GROUPS_MANAGER['AUTH_MODELS_SYNC'] = True
        w.delete()

        # change sync between member creation and deletion
        settings.GROUPS_MANAGER['AUTH_MODELS_SYNC'] = False
        m = testproject_models.OrganizationMember(first_name='Name',
                                                  last_name='Surname')
        m.save()
        self.assertIsNone(m.django_user)
        settings.GROUPS_MANAGER['AUTH_MODELS_SYNC'] = True
        m.delete()

        settings.GROUPS_MANAGER['AUTH_MODELS_SYNC'] = True
        w = testproject_models.WorkGroup(name='New workgroup')
        w.save()
        m = testproject_models.OrganizationMember(first_name='Name',
                                                  last_name='Surname')
        m.save()
        # add to group outside membership
        m.django_user.groups.add(w.django_group)
        w.add_member(m)
        self.assertTrue(w.django_group in m.django_user.groups.all())
        w.remove_member(m)
        # delete django group
        w.django_group = None
        w.add_member(m)
Пример #2
0
    def test_models_sync_inconsistencies_group_member(self):
        from groups_manager import settings
        settings.GROUPS_MANAGER = deepcopy(GROUPS_MANAGER_MOCK)

        # change sync between group creation and deletion
        w = testproject_models.WorkGroup(name='New workgroup')
        w.save()
        m = testproject_models.OrganizationMember(first_name='Name',
                                                  last_name='Surname')
        m.save()

        # remove django group from django user manually
        w.add_member(m)
        m.django_user.groups.remove(w.django_group)
        w.remove_member(m)

        # manually remove django group
        w.add_member(m)
        g = w.django_group
        w.django_group = None
        w.remove_member(m)
        w.django_group = g

        # manually delete django group
        w.add_member(m)
        g = w.django_group
        g.delete()
        w.remove_member(m)