Commit b788b9d6 by Chris Dodge

add to existing test cases to exercise the 'course extras as modules' work in…

add to existing test cases to exercise the 'course extras as modules' work in the CMS import. Also add to the existing 'full' test data collection to include policy, tabs, etc.
parent 17528906
......@@ -94,6 +94,8 @@ class XmlDescriptor(XModuleDescriptor):
'name', 'slug')
metadata_to_strip = ('data_dir',
# cdodge: @TODO: We need to figure out a way to export out 'tabs' and 'grading_policy' which is on the course
'tabs', 'grading_policy',
# VS[compat] -- remove the below attrs once everything is in the CMS
'course', 'org', 'url_name', 'filename')
......@@ -355,7 +357,8 @@ class XmlDescriptor(XModuleDescriptor):
for attr in sorted(self.own_metadata):
# don't want e.g. data_dir
if attr not in self.metadata_to_strip:
xml_object.set(attr, val_for_xml(attr))
val = val_for_xml(attr)
xml_object.set(attr, val)
if self.export_to_file():
# Write the definition to a file
......
{
"GRADER" : [
{
"type" : "Homework",
"min_count" : 3,
"drop_count" : 1,
"short_label" : "HW",
"weight" : 0.5
},
{
"type" : "Final",
"name" : "Final Question",
"short_label" : "Final",
"weight" : 0.5
}
],
"GRADE_CUTOFFS" : {
"A" : 0.8,
"B" : 0.7,
"C" : 0.44
}
}
{
"course/6.002_Spring_2012": {
"graceperiod": "1 day 12 hours 59 minutes 59 seconds",
"start": "2012-09-21T12:00",
"display_name": "Testing",
"xqa_key": "5HapHs6tHhu1iN1ZX5JGNYKRkXrXh7NC",
"tabs": [
{"type": "courseware"},
{"type": "course_info", "name": "Course Info"},
{"type": "static_tab", "url_slug": "syllabus", "name": "Syllabus"},
{"type": "discussion", "name": "Discussion"},
{"type": "wiki", "name": "Wiki"},
{"type": "progress", "name": "Progress"}
]
}
}
\ No newline at end of file
<h1>This is a sample tab</h1>
\ No newline at end of file
......@@ -23,6 +23,7 @@ from static_replace import replace_urls, try_staticfiles_lookup
from courseware.access import has_access
import branding
from courseware.models import StudentModuleCache
from xmodule.modulestore.exceptions import ItemNotFoundError
log = logging.getLogger(__name__)
......@@ -147,7 +148,7 @@ def get_course_about_section(course, section_key):
request = get_request_for_thread()
loc = course.location._replace(category='about', name=section_key)
course_module = get_module(request.user, request, loc, None, course.id)
course_module = get_module(request.user, request, loc, None, course.id, not_found_ok = True)
html = ''
......
......@@ -28,6 +28,8 @@ from xmodule.x_module import ModuleSystem
from xmodule.error_module import ErrorDescriptor, NonStaffErrorDescriptor
from xmodule_modifiers import replace_course_urls, replace_static_urls, add_histogram, wrap_xmodule
from xmodule.modulestore.exceptions import ItemNotFoundError
log = logging.getLogger("mitx.courseware")
......@@ -112,7 +114,7 @@ def toc_for_course(user, request, course, active_chapter, active_section):
return chapters
def get_module(user, request, location, student_module_cache, course_id, position=None):
def get_module(user, request, location, student_module_cache, course_id, position=None, not_found_ok = False):
"""
Get an instance of the xmodule class identified by location,
setting the state based on an existing StudentModule, or creating one if none
......@@ -134,6 +136,10 @@ def get_module(user, request, location, student_module_cache, course_id, positio
"""
try:
return _get_module(user, request, location, student_module_cache, course_id, position)
except ItemNotFoundError:
if not not_found_ok:
log.exception("Error in get_module")
return None
except:
# Something has gone terribly wrong, but still not letting it turn into a 500.
log.exception("Error in get_module")
......
......@@ -250,6 +250,33 @@ class PageLoader(ActivateLoginTestCase):
n += 1
print "Checking ", descriptor.location.url()
# We have ancillary course information now as modules and we can't simply use 'jump_to' to view them
if descriptor.location.category == 'about':
resp = self.client.get(reverse('about_course', kwargs={'course_id': course_id}))
msg = str(resp.status_code)
if resp.status_code != 200:
msg = "ERROR " + msg
all_ok = False
num_bad += 1
elif descriptor.location.category == 'static_tab':
resp = self.client.get(reverse('static_tab', kwargs={'course_id': course_id, 'tab_slug' : descriptor.location.name}))
msg = str(resp.status_code)
if resp.status_code != 200:
msg = "ERROR " + msg
all_ok = False
num_bad += 1
elif descriptor.location.category == 'course_info':
resp = self.client.get(reverse('info', kwargs={'course_id': course_id}))
msg = str(resp.status_code)
if resp.status_code != 200:
msg = "ERROR " + msg
all_ok = False
num_bad += 1
else:
#print descriptor.__class__, descriptor.location
resp = self.client.get(reverse('jump_to',
kwargs={'course_id': course_id,
......@@ -257,10 +284,10 @@ class PageLoader(ActivateLoginTestCase):
msg = str(resp.status_code)
if resp.status_code != 302:
# cdodge: we're adding new module category as part of the Studio work
# such as 'course_info', etc, which are not supposed to be jump_to'able
# so a successful return value here should be a 404
if descriptor.location.category not in ['about', 'static_tab', 'course_info', 'custom_tag_template'] or resp.status_code != 404:
# cdodge: we're adding 'custom_tag_template' which is the Mako template used to render
# the custom tag. We can't 'jump-to' this module. Unfortunately, we also can't test render
# it easily
if descriptor.location.category not in ['custom_tag_template'] or resp.status_code != 404:
msg = "ERROR " + msg
all_ok = False
num_bad += 1
......
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