Commit 8fe55c9a by Don Mitchell

Fix acceptance tests to work w/ split

11300
parent 4ca5012f
...@@ -50,11 +50,17 @@ def get_an_error_dialog(step): ...@@ -50,11 +50,17 @@ def get_an_error_dialog(step):
@step('I can click to go to the unit with the error$') @step('I can click to go to the unit with the error$')
def i_click_on_error_dialog(step): def i_click_on_error_dialog(step):
world.click_link_by_text('Correct failed component') world.click_link_by_text('Correct failed component')
assert_true(world.css_html("span.inline-error").startswith("Problem i4x://MITx/999/problem"))
course_key = SlashSeparatedCourseKey("MITx", "999", "Robot_Super_Course") problem_string = unicode(world.scenario_dict['COURSE'].id.make_usage_key("problem", 'ignore'))
problem_string = u"Problem {}".format(problem_string[:problem_string.rfind('ignore')])
assert_true(
world.css_html("span.inline-error").startswith(problem_string),
u"{} does not start with {}".format(
world.css_html("span.inline-error"), problem_string
))
# we don't know the actual ID of the vertical. So just check that we did go to a # we don't know the actual ID of the vertical. So just check that we did go to a
# vertical page in the course (there should only be one). # vertical page in the course (there should only be one).
vertical_usage_key = course_key.make_usage_key("vertical", None) vertical_usage_key = world.scenario_dict['COURSE'].id.make_usage_key("vertical", None)
vertical_url = reverse_usage_url('container_handler', vertical_usage_key) vertical_url = reverse_usage_url('container_handler', vertical_usage_key)
# Remove the trailing "/None" from the URL - we don't know the course ID, so we just want to # Remove the trailing "/None" from the URL - we don't know the course ID, so we just want to
# check that we visited a vertical URL. # check that we visited a vertical URL.
......
...@@ -24,14 +24,14 @@ Feature: CMS.HTML Editor ...@@ -24,14 +24,14 @@ Feature: CMS.HTML Editor
Given I have created a Blank HTML Page Given I have created a Blank HTML Page
When I edit the page When I edit the page
And I add an image with static link "/static/image.jpg" via the Image Plugin Icon And I add an image with static link "/static/image.jpg" via the Image Plugin Icon
Then the src link is rewritten to "c4x/MITx/999/asset/image.jpg" Then the src link is rewritten to the asset link "image.jpg"
And the link is shown as "/static/image.jpg" in the Image Plugin And the link is shown as "/static/image.jpg" in the Image Plugin
Scenario: TinyMCE link plugin sets urls correctly Scenario: TinyMCE link plugin sets urls correctly
Given I have created a Blank HTML Page Given I have created a Blank HTML Page
When I edit the page When I edit the page
And I add a link with static link "/static/image.jpg" via the Link Plugin Icon And I add a link with static link "/static/image.jpg" via the Link Plugin Icon
Then the href link is rewritten to "c4x/MITx/999/asset/image.jpg" Then the href link is rewritten to the asset link "image.jpg"
And the link is shown as "/static/image.jpg" in the Link Plugin And the link is shown as "/static/image.jpg" in the Link Plugin
Scenario: TinyMCE and CodeMirror preserve style tags Scenario: TinyMCE and CodeMirror preserve style tags
...@@ -76,7 +76,7 @@ Feature: CMS.HTML Editor ...@@ -76,7 +76,7 @@ Feature: CMS.HTML Editor
Given I have created a Blank HTML Page Given I have created a Blank HTML Page
When I edit the page When I edit the page
And type "<img src="/static/image.jpg">" in the code editor and press OK And type "<img src="/static/image.jpg">" in the code editor and press OK
Then the src link is rewritten to "c4x/MITx/999/asset/image.jpg" Then the src link is rewritten to the asset link "image.jpg"
And the code editor displays "<p><img src="/static/image.jpg" /></p>" And the code editor displays "<p><img src="/static/image.jpg" /></p>"
Scenario: Code format toolbar button wraps text with code tags Scenario: Code format toolbar button wraps text with code tags
......
...@@ -155,20 +155,20 @@ def check_raw_editor_text(step): ...@@ -155,20 +155,20 @@ def check_raw_editor_text(step):
assert_equal(step.multiline, get_codemirror_value(0)) assert_equal(step.multiline, get_codemirror_value(0))
@step('the src link is rewritten to "(.*)"$') @step('the src link is rewritten to the asset link "(.*)"$')
def image_static_link_is_rewritten(step, path): def image_static_link_is_rewritten(step, path):
# Find the TinyMCE iframe within the main window # Find the TinyMCE iframe within the main window
with world.browser.get_iframe('mce_0_ifr') as tinymce: with world.browser.get_iframe('mce_0_ifr') as tinymce:
image = tinymce.find_by_tag('img').first image = tinymce.find_by_tag('img').first
assert_in(path, image['src']) assert_in(unicode(world.scenario_dict['COURSE'].id.make_asset_key('asset', path)), image['src'])
@step('the href link is rewritten to "(.*)"$') @step('the href link is rewritten to the asset link "(.*)"$')
def link_static_link_is_rewritten(step, path): def link_static_link_is_rewritten(step, path):
# Find the TinyMCE iframe within the main window # Find the TinyMCE iframe within the main window
with world.browser.get_iframe('mce_0_ifr') as tinymce: with world.browser.get_iframe('mce_0_ifr') as tinymce:
link = tinymce.find_by_tag('a').first link = tinymce.find_by_tag('a').first
assert_in(path, link['href']) assert_in(unicode(world.scenario_dict['COURSE'].id.make_asset_key('asset', path)), link['href'])
@step('the expected toolbar buttons are displayed$') @step('the expected toolbar buttons are displayed$')
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
import urllib import urllib
from lettuce import world from lettuce import world
from django.contrib.auth.models import User, Group from django.contrib.auth.models import User
from student.models import CourseEnrollment from student.models import CourseEnrollment
from xmodule.modulestore.django import modulestore, clear_existing_modulestores from xmodule.modulestore.django import modulestore, clear_existing_modulestores
from xmodule.contentstore.django import _CONTENTSTORE from xmodule.contentstore.django import _CONTENTSTORE
...@@ -33,7 +33,7 @@ def log_in(username='robot', password='test', email='robot@edx.org', name="Robot ...@@ -33,7 +33,7 @@ def log_in(username='robot', password='test', email='robot@edx.org', name="Robot
Use the auto_auth feature to programmatically log the user in Use the auto_auth feature to programmatically log the user in
""" """
url = '/auto_auth' url = '/auto_auth'
params = { 'username': username, 'password': password, 'email': email, 'full_name': name } params = {'username': username, 'password': password, 'email': email, 'full_name': name}
url += "?" + urllib.urlencode(params) url += "?" + urllib.urlencode(params)
world.visit(url) world.visit(url)
......
...@@ -78,12 +78,14 @@ def create_course(_step, course): ...@@ -78,12 +78,14 @@ def create_course(_step, course):
parent_location=world.scenario_dict['COURSE'].location, parent_location=world.scenario_dict['COURSE'].location,
category='chapter', category='chapter',
display_name='Test Chapter', display_name='Test Chapter',
publish_item=True, # Not needed for direct-only but I'd rather the test didn't know that
) )
world.scenario_dict['SECTION'] = world.ItemFactory.create( world.scenario_dict['SECTION'] = world.ItemFactory.create(
parent_location=world.scenario_dict['CHAPTER'].location, parent_location=world.scenario_dict['CHAPTER'].location,
category='sequential', category='sequential',
display_name='Test Section', display_name='Test Section',
publish_item=True,
) )
...@@ -118,12 +120,10 @@ def go_into_course(step): ...@@ -118,12 +120,10 @@ def go_into_course(step):
step.given('And I click on View Courseware') step.given('And I click on View Courseware')
# Do we really use these 3 w/ a different course than is in the scenario_dict? if so, why? If not,
# then get rid of the override arg
def course_id(course_num): def course_id(course_num):
return SlashSeparatedCourseKey( return world.scenario_dict['COURSE'].id.replace(course=course_num)
world.scenario_dict['COURSE'].org,
course_num,
world.scenario_dict['COURSE'].url_name
)
def course_location(course_num): def course_location(course_num):
...@@ -143,8 +143,8 @@ def visit_scenario_item(item_key): ...@@ -143,8 +143,8 @@ def visit_scenario_item(item_key):
url = django_url(reverse( url = django_url(reverse(
'jump_to', 'jump_to',
kwargs={ kwargs={
'course_id': world.scenario_dict['COURSE'].id.to_deprecated_string(), 'course_id': unicode(world.scenario_dict['COURSE'].id),
'location': world.scenario_dict[item_key].location.to_deprecated_string(), 'location': unicode(world.scenario_dict[item_key].location),
} }
)) ))
...@@ -157,8 +157,8 @@ def get_courses(): ...@@ -157,8 +157,8 @@ def get_courses():
Courses are sorted by course.number. Courses are sorted by course.number.
''' '''
courses = [c for c in modulestore().get_courses() courses = [c for c in modulestore().get_courses()
if isinstance(c, CourseDescriptor)] if isinstance(c, CourseDescriptor)] # skip error descriptors
courses = sorted(courses, key=lambda course: course.number) courses = sorted(courses, key=lambda course: course.location.course)
return courses return courses
...@@ -223,13 +223,16 @@ def get_courseware_with_tabs(course_id): ...@@ -223,13 +223,16 @@ def get_courseware_with_tabs(course_id):
course = get_course_by_id(course_id) course = get_course_by_id(course_id)
chapters = [chapter for chapter in course.get_children() if not chapter.hide_from_toc] chapters = [chapter for chapter in course.get_children() if not chapter.hide_from_toc]
courseware = [{'chapter_name': c.display_name_with_default, courseware = [{
'sections': [{'section_name': s.display_name_with_default, 'chapter_name': c.display_name_with_default,
'clickable_tab_count': len(s.get_children()) if (type(s) == seq_module.SequenceDescriptor) else 0, 'sections': [{
'tabs': [{'children_count': len(t.get_children()) if (type(t) == vertical_module.VerticalDescriptor) else 0, 'section_name': s.display_name_with_default,
'class': t.__class__.__name__} 'clickable_tab_count': len(s.get_children()) if (type(s) == seq_module.SequenceDescriptor) else 0,
for t in s.get_children()]} 'tabs': [{
for s in c.get_children() if not s.hide_from_toc]} 'children_count': len(t.get_children()) if (type(t) == vertical_module.VerticalDescriptor) else 0,
for c in chapters] 'class': t.__class__.__name__} for t in s.get_children()
]
} for s in c.get_children() if not s.hide_from_toc]
} for c in chapters]
return courseware return courseware
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