Factory Cleanup
- Corrected import ordering - Using a constant for the User password ECOM-4896
This commit is contained in:
@@ -1,28 +1,31 @@
|
||||
"""Provides factories for student models."""
|
||||
import random
|
||||
|
||||
from student.models import (User, UserProfile, Registration,
|
||||
CourseEnrollmentAllowed, CourseEnrollment,
|
||||
PendingEmailChange, UserStanding,
|
||||
CourseAccessRole)
|
||||
from course_modes.models import CourseMode
|
||||
from django.contrib.auth.models import Group, AnonymousUser
|
||||
from datetime import datetime
|
||||
from uuid import uuid4
|
||||
|
||||
import factory
|
||||
from django.contrib.auth.models import Group, AnonymousUser
|
||||
from factory import lazy_attribute
|
||||
from factory.django import DjangoModelFactory
|
||||
from uuid import uuid4
|
||||
from pytz import UTC
|
||||
from opaque_keys.edx.locations import SlashSeparatedCourseKey
|
||||
from pytz import UTC
|
||||
|
||||
from course_modes.models import CourseMode
|
||||
from student.models import (
|
||||
User, UserProfile, Registration, CourseEnrollmentAllowed, CourseEnrollment, PendingEmailChange, UserStanding,
|
||||
CourseAccessRole
|
||||
)
|
||||
|
||||
# Factories are self documenting
|
||||
# pylint: disable=missing-docstring
|
||||
|
||||
USER_PASSWORD = 'test'
|
||||
|
||||
|
||||
class GroupFactory(DjangoModelFactory):
|
||||
class Meta(object):
|
||||
model = Group
|
||||
django_get_or_create = ('name', )
|
||||
django_get_or_create = ('name',)
|
||||
|
||||
name = factory.Sequence(u'group{0}'.format)
|
||||
|
||||
@@ -39,7 +42,7 @@ class UserStandingFactory(DjangoModelFactory):
|
||||
class UserProfileFactory(DjangoModelFactory):
|
||||
class Meta(object):
|
||||
model = UserProfile
|
||||
django_get_or_create = ('user', )
|
||||
django_get_or_create = ('user',)
|
||||
|
||||
user = None
|
||||
name = factory.LazyAttribute(u'{0.user.first_name} {0.user.last_name}'.format)
|
||||
@@ -83,7 +86,7 @@ class UserFactory(DjangoModelFactory):
|
||||
|
||||
username = factory.Sequence(u'robot{0}'.format)
|
||||
email = factory.Sequence(u'robot+test+{0}@edx.org'.format)
|
||||
password = factory.PostGenerationMethodCall('set_password', 'test')
|
||||
password = factory.PostGenerationMethodCall('set_password', USER_PASSWORD)
|
||||
first_name = factory.Sequence(u'Robot{0}'.format)
|
||||
last_name = 'Test'
|
||||
is_staff = False
|
||||
@@ -155,6 +158,7 @@ class PendingEmailChangeFactory(DjangoModelFactory):
|
||||
new_email: sequence of new+email+{}@edx.org
|
||||
activation_key: sequence of integers, padded to 30 characters
|
||||
"""
|
||||
|
||||
class Meta(object):
|
||||
model = PendingEmailChange
|
||||
|
||||
|
||||
Reference in New Issue
Block a user