예제 #1
0
 def login(self):
     profile = UserProfileFactory(user__username='******',
                                  user__password='******')
     user = profile.user
     success = self.client.login(username=user.username, password='******')
     self.assertTrue(success)
     return user
예제 #2
0
def populate_users():
    """
    Create and returns a list of user, each one belonging to a relevant group.
    Create those group if needed.
    """

    users_to_create = [
        { 'username': '******' , 'groups': [GROUP_PATH_MANAGER] },
        { 'username': '******' , 'groups': [GROUP_TREKKING_MANAGER] },
        { 'username': '******'       , 'groups': [GROUP_EDITOR] },
    ]

    # Get or create all needed relevant groups
    populate_groups()

    created_user_profiles = []

    for user in users_to_create:
        created_user_profiles.append(
            UserProfileFactory(
                user__username=user['username'],
                user__groups=Group.objects.filter(name__in=user['groups']),
        ))

    return created_user_profiles