# Path: groups_manager/models.py
# def get_auth_models_sync_func_default(instance):
#     def group_model(self):
#     def group_member_model(self):
#     def __unicode__(self):
#     def __str__(self):
#     def save(self, *args, **kwargs):
#     def full_name(self):
#     def groups(self):
#     def has_perm(self, perm, obj=None):
#     def has_perms(self, perm_list, obj=None):
#     def assign_object(self, group, obj, **kwargs):
# def member_save(sender, instance, created, *args, **kwargs):
# def member_delete(sender, instance, *args, **kwargs):
#     def __unicode__(self):
#     def __str__(self):
#     def save(self, *args, **kwargs):
#     def groups(self):
#     def __unicode__(self):
#     def __str__(self):
#     def save(self, *args, **kwargs):
#     def groups(self):
#     def member_model(self):
#     def group_member_model(self):
#     def group_members_attribute(self):
#     def __unicode__(self):
#     def __str__(self):
#     def save(self, *args, **kwargs):
#     def _get_full_name(self):
#     def subgroups(self):
#     def get_members(self, subgroups=False):
#     def members(self):
#     def users(self):
#     def get_entities(self, subgroups=False):
#     def entities(self):
#     def add_member(self, member, roles=None, expiration_date=None):
#     def remove_member(self, member):
#     def assign_object(self, obj, **kwargs):
# def group_save(sender, instance, created, *args, **kwargs):
# def group_delete(sender, instance, *args, **kwargs):
#     def __unicode__(self):
#     def __str__(self):
#     def save(self, *args, **kwargs):
#     def __unicode__(self):
#     def __str__(self):
#     def assign_object(self, obj, **kwargs):
# def group_member_save(sender, instance, created, *args, **kwargs):
# def group_member_delete(sender, instance, *args, **kwargs):
# class MemberRelationsMixin(object):
#     class GroupsManagerMeta:
# class MemberMixin(MemberRelationsMixin, models.Model):
#     class Meta:
# class Member(MemberMixin):
#     class Meta(MemberMixin.Meta):
# class GroupTypeMixin(models.Model):
#     class Meta:
# class GroupType(GroupTypeMixin):
#     class Meta(GroupTypeMixin.Meta):
# class GroupEntityMixin(models.Model):
#     class Meta:
# class GroupEntity(GroupEntityMixin):
#     class Meta(GroupEntityMixin.Meta):
# class GroupRelationsMixin(object):
#     class GroupsManagerMeta:
# class GroupMixin(GroupRelationsMixin, MPTTModel):
#     class Meta:
#     class MPTTMeta:
#     class GroupsManagerMeta(GroupRelationsMixin.GroupsManagerMeta):
# class Group(GroupMixin):
#     class Meta(GroupMixin.Meta):
# class GroupMemberRoleMixin(models.Model):
#     class Meta:
# class GroupMemberRole(GroupMemberRoleMixin):
#     class Meta(GroupMemberRoleMixin.Meta):
# class GroupMemberMixin(models.Model):
#     class Meta:
# class GroupMember(GroupMemberMixin):
#     class Meta(GroupMemberMixin.Meta):
# 
# Path: groups_manager/exceptions_gm.py
# class MemberDjangoUserSyncError(BaseException):
# class GroupDjangoGroupSyncError(BaseException):
# class GroupNotSavedError(BaseException):
# class MemberNotSavedError(BaseException):
# class GetGroupMemberError(BaseException):
# class GetRoleError(BaseException):


from copy import deepcopy
from django.contrib.auth import get_user_model
from django.contrib.auth.models import Group as DjangoGroup
from django.test import TestCase
from groups_manager import models, exceptions_gm
        from groups_manager import settings
        from groups_manager import settings
        from groups_manager import settings
        from groups_manager import settings
        from groups_manager import settings
        from groups_manager import settings
        from groups_manager import settings
        from groups_manager import settings
        from groups_manager import settings
        from groups_manager import settings
        from groups_manager import settings
        from groups_manager import settings
import re
import sys
                                              email='julius_caesar@ancient_rome.com')
        self.assertEqual(member.username, 'giulio_cesare')

    def test_member_save(self):
        settings.GROUPS_MANAGER = deepcopy(GROUPS_MANAGER_MOCK)
        member = models.Member.objects.create(first_name='Caio', last_name='Mario')
        self.assertIsNotNone(member.django_user)
        self.assertTrue(member.django_user.username.startswith(
                GROUPS_MANAGER_MOCK['USER_USERNAME_PREFIX']))
        self.assertTrue(re.search(random_end, member.django_user.username))

    def test_member_save_no_prefix_suffix(self):
        empty_ps = deepcopy(GROUPS_MANAGER_MOCK)
        empty_ps['USER_USERNAME_PREFIX'] = ''
        empty_ps['USER_USERNAME_SUFFIX'] = ''
        settings.GROUPS_MANAGER = empty_ps
        member = models.Member.objects.create(first_name='Caio', last_name='Mario')
        self.assertEqual(member.username, member.django_user.username)

    def test_member_save_to_existing_user(self):
        empty_ps = deepcopy(GROUPS_MANAGER_MOCK)
        empty_ps['USER_USERNAME_PREFIX'] = ''
        empty_ps['USER_USERNAME_SUFFIX'] = ''
        settings.GROUPS_MANAGER = empty_ps
        django_user = get_user_model().objects.create(username='caio_mario')
        member = models.Member.objects.create(first_name='Caio', last_name='Mario')
        self.assertEqual(django_user, member.django_user)

    def test_has_perm_exception(self):
        member = models.Member(first_name='Caio', last_name='Mario')

# Path: groups_manager/models.py
# def get_auth_models_sync_func_default(instance):
#     def group_model(self):
#     def group_member_model(self):
#     def __unicode__(self):
#     def __str__(self):
#     def save(self, *args, **kwargs):
#     def full_name(self):
#     def groups(self):
#     def has_perm(self, perm, obj=None):
#     def has_perms(self, perm_list, obj=None):
#     def assign_object(self, group, obj, **kwargs):
# def member_save(sender, instance, created, *args, **kwargs):
# def member_delete(sender, instance, *args, **kwargs):
#     def __unicode__(self):
#     def __str__(self):
#     def save(self, *args, **kwargs):
#     def groups(self):
#     def __unicode__(self):
#     def __str__(self):
#     def save(self, *args, **kwargs):
#     def groups(self):
#     def member_model(self):
#     def group_member_model(self):
#     def group_members_attribute(self):
#     def __unicode__(self):
#     def __str__(self):
#     def save(self, *args, **kwargs):
#     def _get_full_name(self):
#     def subgroups(self):
#     def get_members(self, subgroups=False):
#     def members(self):
#     def users(self):
#     def get_entities(self, subgroups=False):
#     def entities(self):
#     def add_member(self, member, roles=None, expiration_date=None):
#     def remove_member(self, member):
#     def assign_object(self, obj, **kwargs):
# def group_save(sender, instance, created, *args, **kwargs):
# def group_delete(sender, instance, *args, **kwargs):
#     def __unicode__(self):
#     def __str__(self):
#     def save(self, *args, **kwargs):
#     def __unicode__(self):
#     def __str__(self):
#     def assign_object(self, obj, **kwargs):
# def group_member_save(sender, instance, created, *args, **kwargs):
# def group_member_delete(sender, instance, *args, **kwargs):
# class MemberRelationsMixin(object):
#     class GroupsManagerMeta:
# class MemberMixin(MemberRelationsMixin, models.Model):
#     class Meta:
# class Member(MemberMixin):
#     class Meta(MemberMixin.Meta):
# class GroupTypeMixin(models.Model):
#     class Meta:
# class GroupType(GroupTypeMixin):
#     class Meta(GroupTypeMixin.Meta):
# class GroupEntityMixin(models.Model):
#     class Meta:
# class GroupEntity(GroupEntityMixin):
#     class Meta(GroupEntityMixin.Meta):
# class GroupRelationsMixin(object):
#     class GroupsManagerMeta:
# class GroupMixin(GroupRelationsMixin, MPTTModel):
#     class Meta:
#     class MPTTMeta:
#     class GroupsManagerMeta(GroupRelationsMixin.GroupsManagerMeta):
# class Group(GroupMixin):
#     class Meta(GroupMixin.Meta):
# class GroupMemberRoleMixin(models.Model):
#     class Meta:
# class GroupMemberRole(GroupMemberRoleMixin):
#     class Meta(GroupMemberRoleMixin.Meta):
# class GroupMemberMixin(models.Model):
#     class Meta:
# class GroupMember(GroupMemberMixin):
#     class Meta(GroupMemberMixin.Meta):
# 
# Path: groups_manager/exceptions_gm.py
# class MemberDjangoUserSyncError(BaseException):
# class GroupDjangoGroupSyncError(BaseException):
# class GroupNotSavedError(BaseException):
# class MemberNotSavedError(BaseException):
# class GetGroupMemberError(BaseException):
# class GetRoleError(BaseException):


# Path: groups_manager/tests/test_models.py
from copy import deepcopy
from django.contrib.auth import get_user_model
from django.contrib.auth.models import Group as DjangoGroup
from django.test import TestCase
from groups_manager import models, exceptions_gm
        from groups_manager import settings
        from groups_manager import settings
        from groups_manager import settings
        from groups_manager import settings
        from groups_manager import settings
        from groups_manager import settings
        from groups_manager import settings
        from groups_manager import settings
        from groups_manager import settings
        from groups_manager import settings
        from groups_manager import settings
        from groups_manager import settings
import re
import sys

                                              email='julius_caesar@ancient_rome.com')
        self.assertEqual(member.username, 'giulio_cesare')

    def test_member_save(self):
        settings.GROUPS_MANAGER = deepcopy(GROUPS_MANAGER_MOCK)
        member = models.Member.objects.create(first_name='Caio', last_name='Mario')
        self.assertIsNotNone(member.django_user)
        self.assertTrue(member.django_user.username.startswith(
                GROUPS_MANAGER_MOCK['USER_USERNAME_PREFIX']))
        self.assertTrue(re.search(random_end, member.django_user.username))

    def test_member_save_no_prefix_suffix(self):
        empty_ps = deepcopy(GROUPS_MANAGER_MOCK)
        empty_ps['USER_USERNAME_PREFIX'] = ''
        empty_ps['USER_USERNAME_SUFFIX'] = ''
        settings.GROUPS_MANAGER = empty_ps
        member = models.Member.objects.create(first_name='Caio', last_name='Mario')
        self.assertEqual(member.username, member.django_user.username)

    def test_member_save_to_existing_user(self):
        empty_ps = deepcopy(GROUPS_MANAGER_MOCK)
        empty_ps['USER_USERNAME_PREFIX'] = ''
        empty_ps['USER_USERNAME_SUFFIX'] = ''
        settings.GROUPS_MANAGER = empty_ps
        django_user = get_user_model().objects.create(username='caio_mario')
        member = models.Member.objects.create(first_name='Caio', last_name='Mario')
        self.assertEqual(django_user, member.django_user)

    def test_has_perm_exception(self):
        member = models.Member(first_name='Caio', last_name='Mario')

        with self.assertRaises(exceptions_gm.MemberDjangoUserSyncError):