Commit 3576a315 by Jay Zoldak

Repoint factory references in lettuce tests to world.

parent 1c4ffcf1
from lettuce import world, step from lettuce import world, step
from terrain.factories import *
from common import * from common import *
from nose.tools import assert_true, assert_false, assert_equal from nose.tools import assert_true, assert_false, assert_equal
...@@ -10,15 +9,15 @@ logger = getLogger(__name__) ...@@ -10,15 +9,15 @@ logger = getLogger(__name__)
@step(u'I have a course with no sections$') @step(u'I have a course with no sections$')
def have_a_course(step): def have_a_course(step):
clear_courses() clear_courses()
course = CourseFactory.create() course = world.CourseFactory.create()
@step(u'I have a course with 1 section$') @step(u'I have a course with 1 section$')
def have_a_course_with_1_section(step): def have_a_course_with_1_section(step):
clear_courses() clear_courses()
course = CourseFactory.create() course = world.CourseFactory.create()
section = ItemFactory.create(parent_location=course.location) section = world.ItemFactory.create(parent_location=course.location)
subsection1 = ItemFactory.create( subsection1 = world.ItemFactory.create(
parent_location=section.location, parent_location=section.location,
template='i4x://edx/templates/sequential/Empty', template='i4x://edx/templates/sequential/Empty',
display_name='Subsection One',) display_name='Subsection One',)
...@@ -27,20 +26,20 @@ def have_a_course_with_1_section(step): ...@@ -27,20 +26,20 @@ def have_a_course_with_1_section(step):
@step(u'I have a course with multiple sections$') @step(u'I have a course with multiple sections$')
def have_a_course_with_two_sections(step): def have_a_course_with_two_sections(step):
clear_courses() clear_courses()
course = CourseFactory.create() course = world.CourseFactory.create()
section = ItemFactory.create(parent_location=course.location) section = world.ItemFactory.create(parent_location=course.location)
subsection1 = ItemFactory.create( subsection1 = world.ItemFactory.create(
parent_location=section.location, parent_location=section.location,
template='i4x://edx/templates/sequential/Empty', template='i4x://edx/templates/sequential/Empty',
display_name='Subsection One',) display_name='Subsection One',)
section2 = ItemFactory.create( section2 = world.ItemFactory.create(
parent_location=course.location, parent_location=course.location,
display_name='Section Two',) display_name='Section Two',)
subsection2 = ItemFactory.create( subsection2 = world.ItemFactory.create(
parent_location=section2.location, parent_location=section2.location,
template='i4x://edx/templates/sequential/Empty', template='i4x://edx/templates/sequential/Empty',
display_name='Subsection Alpha',) display_name='Subsection Alpha',)
subsection3 = ItemFactory.create( subsection3 = world.ItemFactory.create(
parent_location=section2.location, parent_location=section2.location,
template='i4x://edx/templates/sequential/Empty', template='i4x://edx/templates/sequential/Empty',
display_name='Subsection Beta',) display_name='Subsection Beta',)
......
from student.models import (User, UserProfile, Registration, from student.models import (User, UserProfile, Registration,
CourseEnrollmentAllowed) CourseEnrollmentAllowed, CourseEnrollment)
from django.contrib.auth.models import Group from django.contrib.auth.models import Group
from datetime import datetime from datetime import datetime
from factory import Factory from factory import Factory, SubFactory
from xmodule.modulestore import Location from xmodule.modulestore import Location
from xmodule.modulestore.django import modulestore from xmodule.modulestore.django import modulestore
from time import gmtime from time import gmtime
...@@ -50,6 +50,13 @@ class UserFactory(Factory): ...@@ -50,6 +50,13 @@ class UserFactory(Factory):
date_joined = datetime(2011, 1, 1) date_joined = datetime(2011, 1, 1)
class CourseEnrollmentFactory(Factory):
FACTORY_FOR = CourseEnrollment
user = SubFactory(UserFactory)
course_id = 'edX/toy/2012_Fall'
class CourseEnrollmentAllowedFactory(Factory): class CourseEnrollmentAllowedFactory(Factory):
FACTORY_FOR = CourseEnrollmentAllowed FACTORY_FOR = CourseEnrollmentAllowed
......
from student.tests.factories import (UserFactory, UserProfileFactory, from student.tests.factories import (UserFactory, UserProfileFactory,
RegistrationFactory, GroupFactory, RegistrationFactory, GroupFactory,
CourseEnrollmentAllowed, CourseEnrollmentAllowed, CourseEnrollment,
CourseFactory, ItemFactory) CourseFactory, ItemFactory)
from lettuce import world from lettuce import world
...@@ -38,6 +38,14 @@ class GroupFactory(GroupFactory): ...@@ -38,6 +38,14 @@ class GroupFactory(GroupFactory):
@world.absorb @world.absorb
class CourseEnrollment(CourseEnrollment):
"""
Courses that the user is enrolled in
"""
pass
@world.absorb
class CourseEnrollmentAllowed(CourseEnrollmentAllowed): class CourseEnrollmentAllowed(CourseEnrollmentAllowed):
""" """
Users allowed to enroll in the course outside of the usual window Users allowed to enroll in the course outside of the usual window
......
...@@ -5,7 +5,6 @@ from lettuce.django import django_url ...@@ -5,7 +5,6 @@ from lettuce.django import django_url
from django.conf import settings from django.conf import settings
from django.contrib.auth.models import User from django.contrib.auth.models import User
from student.models import CourseEnrollment from student.models import CourseEnrollment
from terrain.factories import CourseFactory, ItemFactory
from xmodule.modulestore import Location from xmodule.modulestore import Location
from xmodule.modulestore.django import _MODULESTORES, modulestore from xmodule.modulestore.django import _MODULESTORES, modulestore
from xmodule.templates import update_templates from xmodule.templates import update_templates
...@@ -101,15 +100,15 @@ def create_course(step, course): ...@@ -101,15 +100,15 @@ def create_course(step, course):
# Create the course # Create the course
# We always use the same org and display name, # We always use the same org and display name,
# but vary the course identifier (e.g. 600x or 191x) # but vary the course identifier (e.g. 600x or 191x)
course = CourseFactory.create(org=TEST_COURSE_ORG, course = world.CourseFactory.create(org=TEST_COURSE_ORG,
number=course, number=course,
display_name=TEST_COURSE_NAME) display_name=TEST_COURSE_NAME)
# Add a section to the course to contain problems # Add a section to the course to contain problems
section = ItemFactory.create(parent_location=course.location, section = world.ItemFactory.create(parent_location=course.location,
display_name=TEST_SECTION_NAME) display_name=TEST_SECTION_NAME)
problem_section = ItemFactory.create(parent_location=section.location, problem_section = world.ItemFactory.create(parent_location=section.location,
template='i4x://edx/templates/sequential/Empty', template='i4x://edx/templates/sequential/Empty',
display_name=TEST_SECTION_NAME) display_name=TEST_SECTION_NAME)
...@@ -131,7 +130,7 @@ def i_am_registered_for_the_course(step, course): ...@@ -131,7 +130,7 @@ def i_am_registered_for_the_course(step, course):
@step(u'The course "([^"]*)" has extra tab "([^"]*)"$') @step(u'The course "([^"]*)" has extra tab "([^"]*)"$')
def add_tab_to_course(step, course, extra_tab_name): def add_tab_to_course(step, course, extra_tab_name):
section_item = ItemFactory.create(parent_location=course_location(course), section_item = world.ItemFactory.create(parent_location=course_location(course),
template="i4x://edx/templates/static_tab/Empty", template="i4x://edx/templates/static_tab/Empty",
display_name=str(extra_tab_name)) display_name=str(extra_tab_name))
......
...@@ -4,7 +4,6 @@ from selenium.webdriver.support.ui import Select ...@@ -4,7 +4,6 @@ from selenium.webdriver.support.ui import Select
import random import random
import textwrap import textwrap
from common import i_am_registered_for_the_course, TEST_SECTION_NAME, section_location from common import i_am_registered_for_the_course, TEST_SECTION_NAME, section_location
from terrain.factories import ItemFactory
from capa.tests.response_xml_factory import OptionResponseXMLFactory, \ from capa.tests.response_xml_factory import OptionResponseXMLFactory, \
ChoiceResponseXMLFactory, MultipleChoiceResponseXMLFactory, \ ChoiceResponseXMLFactory, MultipleChoiceResponseXMLFactory, \
StringResponseXMLFactory, NumericalResponseXMLFactory, \ StringResponseXMLFactory, NumericalResponseXMLFactory, \
...@@ -92,7 +91,7 @@ def add_problem_to_course(course, problem_type): ...@@ -92,7 +91,7 @@ def add_problem_to_course(course, problem_type):
# Create a problem item using our generated XML # Create a problem item using our generated XML
# We set rerandomize=always in the metadata so that the "Reset" button # We set rerandomize=always in the metadata so that the "Reset" button
# will appear. # will appear.
problem_item = ItemFactory.create(parent_location=section_location(course), problem_item = world.ItemFactory.create(parent_location=section_location(course),
template="i4x://edx/templates/problem/Blank_Common_Problem", template="i4x://edx/templates/problem/Blank_Common_Problem",
display_name=str(problem_type), display_name=str(problem_type),
data=problem_xml, data=problem_xml,
......
...@@ -8,6 +8,7 @@ import factory ...@@ -8,6 +8,7 @@ import factory
from django.contrib.auth.models import User from django.contrib.auth.models import User
from student.models import UserProfile, CourseEnrollment from student.models import UserProfile, CourseEnrollment
from django_comment_client.models import Role, Permission from django_comment_client.models import Role, Permission
from student.tests.factories import UserFactory, CourseEnrollmentFactory
import django_comment_client.models as models import django_comment_client.models as models
import django_comment_client.utils as utils import django_comment_client.utils as utils
...@@ -15,21 +16,6 @@ import django_comment_client.utils as utils ...@@ -15,21 +16,6 @@ import django_comment_client.utils as utils
import xmodule.modulestore.django as django import xmodule.modulestore.django as django
class UserFactory(factory.Factory):
FACTORY_FOR = User
username = 'robot'
password = '123456'
email = 'robot@edx.org'
is_active = True
is_staff = False
class CourseEnrollmentFactory(factory.Factory):
FACTORY_FOR = CourseEnrollment
user = factory.SubFactory(UserFactory)
course_id = 'edX/toy/2012_Fall'
class RoleFactory(factory.Factory): class RoleFactory(factory.Factory):
FACTORY_FOR = Role FACTORY_FOR = Role
name = 'Student' name = 'Student'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment