Commit 00d25b68 by Will Daly

Moved modulestore flush code into terrain/course_helpers

parent a58ae9b6
...@@ -43,7 +43,7 @@ def i_press_the_category_delete_icon(step, category): ...@@ -43,7 +43,7 @@ def i_press_the_category_delete_icon(step, category):
@step('I have opened a new course in Studio$') @step('I have opened a new course in Studio$')
def i_have_opened_a_new_course(step): def i_have_opened_a_new_course(step):
clear_courses() world.clear_courses()
log_into_studio() log_into_studio()
create_a_course() create_a_course()
...@@ -69,23 +69,6 @@ def create_studio_user( ...@@ -69,23 +69,6 @@ def create_studio_user(
user_profile = world.UserProfileFactory(user=studio_user) user_profile = world.UserProfileFactory(user=studio_user)
def flush_xmodule_store():
# Flush and initialize the module store
# It needs the templates because it creates new records
# by cloning from the template.
# Note that if your test module gets in some weird state
# (though it shouldn't), do this manually
# from the bash shell to drop it:
# $ mongo test_xmodule --eval "db.dropDatabase()"
_MODULESTORES = {}
modulestore().collection.drop()
update_templates()
def clear_courses():
flush_xmodule_store()
def fill_in_course_info( def fill_in_course_info(
name='Robot Super Course', name='Robot Super Course',
org='MITx', org='MITx',
......
...@@ -6,7 +6,7 @@ from common import * ...@@ -6,7 +6,7 @@ from common import *
@step('There are no courses$') @step('There are no courses$')
def no_courses(step): def no_courses(step):
clear_courses() world.clear_courses()
@step('I click the New Course button$') @step('I click the New Course button$')
......
...@@ -8,13 +8,13 @@ logger = getLogger(__name__) ...@@ -8,13 +8,13 @@ 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() world.clear_courses()
course = world.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() world.clear_courses()
course = world.CourseFactory.create() course = world.CourseFactory.create()
section = world.ItemFactory.create(parent_location=course.location) section = world.ItemFactory.create(parent_location=course.location)
subsection1 = world.ItemFactory.create( subsection1 = world.ItemFactory.create(
...@@ -25,7 +25,7 @@ def have_a_course_with_1_section(step): ...@@ -25,7 +25,7 @@ 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() world.clear_courses()
course = world.CourseFactory.create() course = world.CourseFactory.create()
section = world.ItemFactory.create(parent_location=course.location) section = world.ItemFactory.create(parent_location=course.location)
subsection1 = world.ItemFactory.create( subsection1 = world.ItemFactory.create(
......
...@@ -7,7 +7,7 @@ from nose.tools import assert_equal ...@@ -7,7 +7,7 @@ from nose.tools import assert_equal
@step('I have opened a new course section in Studio$') @step('I have opened a new course section in Studio$')
def i_have_opened_a_new_course_section(step): def i_have_opened_a_new_course_section(step):
clear_courses() world.clear_courses()
log_into_studio() log_into_studio()
create_a_course() create_a_course()
add_section() add_section()
......
...@@ -7,6 +7,8 @@ from django.contrib.auth import authenticate, login ...@@ -7,6 +7,8 @@ from django.contrib.auth import authenticate, login
from django.contrib.auth.middleware import AuthenticationMiddleware from django.contrib.auth.middleware import AuthenticationMiddleware
from django.contrib.sessions.middleware import SessionMiddleware from django.contrib.sessions.middleware import SessionMiddleware
from student.models import CourseEnrollment from student.models import CourseEnrollment
from xmodule.modulestore.django import _MODULESTORES, modulestore
from xmodule.templates import update_templates
from bs4 import BeautifulSoup from bs4 import BeautifulSoup
import os.path import os.path
from urllib import quote_plus from urllib import quote_plus
...@@ -119,3 +121,16 @@ def save_the_course_content(path='/tmp'): ...@@ -119,3 +121,16 @@ def save_the_course_content(path='/tmp'):
f = open('%s/%s' % (path, filename), 'w') f = open('%s/%s' % (path, filename), 'w')
f.write(output) f.write(output)
f.close f.close
@world.absorb
def clear_courses():
# Flush and initialize the module store
# It needs the templates because it creates new records
# by cloning from the template.
# Note that if your test module gets in some weird state
# (though it shouldn't), do this manually
# from the bash shell to drop it:
# $ mongo test_xmodule --eval "db.dropDatabase()"
_MODULESTORES = {}
modulestore().collection.drop()
update_templates()
...@@ -24,7 +24,7 @@ def create_course(step, course): ...@@ -24,7 +24,7 @@ def create_course(step, course):
# First clear the modulestore so we don't try to recreate # First clear the modulestore so we don't try to recreate
# the same course twice # the same course twice
# This also ensures that the necessary templates are loaded # This also ensures that the necessary templates are loaded
flush_xmodule_store() world.clear_courses()
# Create the course # Create the course
# We always use the same org and display name, # We always use the same org and display name,
...@@ -65,19 +65,6 @@ def add_tab_to_course(step, course, extra_tab_name): ...@@ -65,19 +65,6 @@ def add_tab_to_course(step, course, extra_tab_name):
display_name=str(extra_tab_name)) display_name=str(extra_tab_name))
def flush_xmodule_store():
# Flush and initialize the module store
# It needs the templates because it creates new records
# by cloning from the template.
# Note that if your test module gets in some weird state
# (though it shouldn't), do this manually
# from the bash shell to drop it:
# $ mongo test_xmodule --eval "db.dropDatabase()"
_MODULESTORES = {}
modulestore().collection.drop()
update_templates()
def course_id(course_num): def course_id(course_num):
return "%s/%s/%s" % (TEST_COURSE_ORG, course_num, return "%s/%s/%s" % (TEST_COURSE_ORG, course_num,
TEST_COURSE_NAME.replace(" ", "_")) TEST_COURSE_NAME.replace(" ", "_"))
......
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