Commit 2721966d by Julian Arni

Added acceptance tests for get_html exception handling

Make tests conform to new import UI
parent faadc33f
......@@ -39,7 +39,6 @@ def click_new_component_button(step, component_button_css):
)
world.css_click(component_button_css)
@world.absorb
def click_component_from_menu(category, boilerplate, expected_css):
"""
......@@ -64,13 +63,11 @@ def edit_component_and_select_settings():
world.css_click('a.edit-button')
world.css_click('#settings-mode a')
@world.absorb
def edit_component():
world.wait_for(lambda _driver: world.css_visible('a.edit-button'))
world.css_click('a.edit-button')
@world.absorb
def verify_setting_entry(setting, display_name, value, explicitly_set):
"""
......@@ -100,7 +97,6 @@ def verify_setting_entry(setting, display_name, value, explicitly_set):
assert_equal(explicitly_set, settingClearButton.has_class('active'))
assert_equal(not explicitly_set, settingClearButton.has_class('inactive'))
@world.absorb
def verify_all_setting_entries(expected_entries):
settings = world.browser.find_by_css('.wrapper-comp-setting')
......@@ -111,7 +107,6 @@ def verify_all_setting_entries(expected_entries):
expected_entries[counter][1], expected_entries[counter][2]
)
@world.absorb
def save_component_and_reopen(step):
world.css_click("a.save-button")
......@@ -121,7 +116,6 @@ def save_component_and_reopen(step):
reload_the_page(step)
edit_component_and_select_settings()
@world.absorb
def cancel_component(step):
world.css_click("a.cancel-button")
......@@ -129,12 +123,10 @@ def cancel_component(step):
# they are not persisted. Refresh the browser to make sure the changes were not persisted.
reload_the_page(step)
@world.absorb
def revert_setting_entry(label):
get_setting_entry(label).find_by_css('.setting-clear')[0].click()
@world.absorb
def get_setting_entry(label):
def get_setting():
......
import os
from lettuce import world
from django.conf import settings
@world.absorb
def import_file(filename):
world.browser.execute_script("$('input.file-input').css('display', 'block')")
path = os.path.join(settings.COMMON_TEST_DATA_ROOT, "imports", filename)
world.browser.attach_file('course-data', os.path.abspath(path))
world.css_click('input.submit-button')
# Go to course outline
menu_css = 'li.nav-course-courseware'
outline_css = 'li.nav-course-courseware-outline a'
world.css_click(menu_css)
world.css_click(outline_css)
@world.absorb
def go_to_import():
menu_css = 'li.nav-course-tools'
import_css = 'li.nav-course-tools-import a'
world.css_click(menu_css)
world.css_click(import_css)
......@@ -3,7 +3,7 @@ Feature: CMS.Problem Editor
As a course author, I want to be able to create problems and edit their settings.
Scenario: User can view metadata
Given I have created a Blank Common Problem
Given I have an empty course
When I edit and select Settings
Then I see the advanced settings and their expected values
And Edit High Level Source is not visible
......@@ -89,3 +89,13 @@ Feature: CMS.Problem Editor
When I edit and compile the High Level Source
Then my change to the High Level Source is persisted
And when I view the High Level Source I see my changes
Scenario: Exceptions don't cause problem to be uneditable (bug STUD-786)
Given I have created a Blank Common Problem
And I go to the import page
And I import the file "get_html_exception_test.tar.gz"
When I go to the unit "Probability and BMI"
And I click on the link "edit a draft"
Then I see a message that says "We're having trouble rendering your component"
And I can edit the problem
# disable missing docstring
#pylint: disable=C0111
import os
import json
from lettuce import world, step
from nose.tools import assert_equal, assert_true # pylint: disable=E0611
from common import type_in_codemirror
from time import sleep
from pdb import set_trace
DISPLAY_NAME = "Display Name"
MAXIMUM_ATTEMPTS = "Maximum Attempts"
......@@ -24,7 +30,7 @@ def i_created_blank_common_problem(step):
@step('I edit and select Settings$')
def i_edit_and_select_settings(step):
def i_edit_and_select_settings(_step):
world.edit_component_and_select_settings()
......@@ -41,7 +47,7 @@ def i_see_advanced_settings_with_values(step):
@step('I can modify the display name')
def i_can_modify_the_display_name(step):
def i_can_modify_the_display_name(_step):
# Verifying that the display name can be a string containing a floating point value
# (to confirm that we don't throw an error because it is of the wrong type).
index = world.get_setting_entry_index(DISPLAY_NAME)
......@@ -58,7 +64,7 @@ def my_display_name_change_is_persisted_on_save(step):
@step('I can specify special characters in the display name')
def i_can_modify_the_display_name_with_special_chars(step):
def i_can_modify_the_display_name_with_special_chars(_step):
index = world.get_setting_entry_index(DISPLAY_NAME)
world.css_fill('.wrapper-comp-setting .setting-input', "updated ' \" &", index=index)
if world.is_firefox():
......@@ -73,7 +79,7 @@ def special_chars_persisted_on_save(step):
@step('I can revert the display name to unset')
def can_revert_display_name_to_unset(step):
def can_revert_display_name_to_unset(_step):
world.revert_setting_entry(DISPLAY_NAME)
verify_unset_display_name()
......@@ -85,7 +91,7 @@ def my_display_name_is_persisted_on_save(step):
@step('I can select Per Student for Randomization')
def i_can_select_per_student_for_randomization(step):
def i_can_select_per_student_for_randomization(_step):
world.browser.select(RANDOMIZATION, "Per Student")
verify_modified_randomization()
......@@ -104,7 +110,7 @@ def i_can_revert_to_default_for_randomization(step):
@step('I can set the weight to "(.*)"?')
def i_can_set_weight(step, weight):
def i_can_set_weight(_step, weight):
set_weight(weight)
verify_modified_weight()
......@@ -175,14 +181,14 @@ def create_latex_problem(step):
@step('I edit and compile the High Level Source')
def edit_latex_source(step):
def edit_latex_source(_step):
open_high_level_source()
type_in_codemirror(1, "hi")
world.css_click('.hls-compile')
@step('my change to the High Level Source is persisted')
def high_level_source_persisted(step):
def high_level_source_persisted(_step):
def verify_text(driver):
css_sel = '.problem div>span'
return world.css_text(css_sel) == 'hi'
......@@ -191,10 +197,55 @@ def high_level_source_persisted(step):
@step('I view the High Level Source I see my changes')
def high_level_source_in_editor(step):
def high_level_source_in_editor(_step):
open_high_level_source()
assert_equal('hi', world.css_value('.source-edit-box'))
@step(u'I have an empty course')
def i_have_empty_course(step):
step.given('I have clicked the new unit button')
@step(u'I go to the import page')
def i_go_to_import(_step):
world.go_to_import()
@step(u'I import the file "([^"]*)"$')
def i_import_the_file(_step, filename):
world.import_file(filename)
@step(u'I click on the link "([^"]*)"$')
def i_click_on(_step, link):
#go = "$(\"a:contains('{0}')\").click()".format(link)
world.browser.click_link_by_text(link)
@step(u'I go to the vertical "([^"]*)"$')
def i_go_to_vertical(_step, vertical):
world.css_click("span:contains('{0}')".format(vertical))
@step(u'I go to the unit "([^"]*)"$')
def i_go_to_unit(_step, unit):
loc = "window.location = $(\"span:contains('{0}')\").closest('a').attr('href')".format(unit)
world.browser.execute_script(loc)
@step(u'I see a message that says "([^"]*)"$')
def i_can_see_message(_step, msg):
msg = json.dumps(msg) # escape quotes
world.browser.is_text_present(msg)
@step(u'I can edit the problem$')
def i_can_edit_problem(_step):
try:
world.edit_component()
except TimeoutException:
assert_true(False)
assert_true(True)
def verify_high_level_source_links(step, visible):
if visible:
......
......@@ -35,6 +35,8 @@ from .access import get_location_and_verify_access
from util.json_request import JsonResponse
from extract_tar import safetar_extractall
import traceback
__all__ = ['import_course', 'import_status', 'generate_export_course', 'export_course']
......@@ -193,6 +195,7 @@ def import_course(request, org, course, name):
if not dirpath:
return JsonResponse(
{
'ErrMsg': _('Could not find the course.xml file in the package.'),
'Stage': 2
},
......@@ -227,7 +230,7 @@ def import_course(request, org, course, name):
except Exception as exception: # pylint: disable=W0703
return JsonResponse(
{
'ErrMsg': str(exception),
'ErrMsg': str(exception) + traceback.format_exc(),
'Stage': session_status[key]
},
status=400
......
<section class="about">
<h2>About This Course</h2>
<p>Include your long course description here. The long course description should contain 150-400 words.</p>
<p>This is paragraph 2 of the long course description. Add more paragraphs as needed. Make sure to enclose them in paragraph tags.</p>
</section>
<section class="prerequisites">
<h2>Prerequisites</h2>
<p>Add information about course prerequisites here.</p>
</section>
<section class="course-staff">
<h2>Course Staff</h2>
<article class="teacher">
<div class="teacher-image">
<img src="/static/images/pl-faculty.png" align="left" style="margin:0 20 px 0">
</div>
<h3>Staff Member #1</h3>
<p>Biography of instructor/staff member #1</p>
</article>
<article class="teacher">
<div class="teacher-image">
<img src="/static/images/pl-faculty.png" align="left" style="margin:0 20 px 0">
</div>
<h3>Staff Member #2</h3>
<p>Biography of instructor/staff member #2</p>
</article>
</section>
<section class="faq">
<section class="responses">
<h2>Frequently Asked Questions</h2>
<article class="response">
<h3>Do I need to buy a textbook?</h3>
<p>No, a free online version of Chemistry: Principles, Patterns, and Applications, First Edition by Bruce Averill and Patricia Eldredge will be available, though you can purchase a printed version (published by FlatWorld Knowledge) if you’d like.</p>
</article>
<article class="response">
<h3>Question #2</h3>
<p>Your answer would be displayed here.</p>
</article>
</section>
</section>
<chapter display_name="Week 1" showanswer="attempted" start="2011-09-19T21:00:00Z">
<sequential url_name="8af0ab4186c04c2eb08a92926e36d1ce"/>
</chapter>
<course url_name="hakj" org="hajkslkjads" course="hksj"/>
<course advanced_modules="[]" allow_anonymous="false" announcement="null" cohort_config="{}" days_early_for_beta="100" display_name="Principles of Biostatistics" due="null" end="2013-12-20T05:00:00Z" enrollment_end="2013-09-25T04:00:00Z" enrollment_start="2013-08-26T04:00:00Z" format="null" giturl="null" graceperiod="900 seconds" graded="false" hide_from_toc="false" html_textbooks="[]" ispublic="false" pdf_textbooks="[]" remote_gradebook="{}" rerandomize="never" show_calculator="Yes" showanswer="attempted" source_file="null" start="2013-08-26T04:00:00Z" tags="[]" xqa_key="AlQ7TjCl7Rfhc0Am6WguqjeUzGz7AuVt">
<chapter url_name="Week_1"/>
</course>
<a href='https://6002x.mitx.mit.edu/discussion/questions/scope:all/sort:activity-desc/tags:${tag}/page:1/'> Discussion: ${tag} </a>
\ No newline at end of file
<a href="/static/handouts/${handout_name}" target="_blank"> ${text_of_link} </a>
<img src="http://pmitros.csail.mit.edu/tutorial/images/${file}" />
<a href="${url_to_link_to}" target="_blank"> ${text_of_link} </a>
Lecture Slides Handout [<a href="/static/handouts/6002-L${lecnum}-oei12-gaps.pdf">Clean </a>][<a href="/static/handouts/6002-L${lecnum}-oei12-gaps-annotated.pdf">Annotated</a>]
\ No newline at end of file
{"GRADER": [{"short_label": "HW", "min_count": 12, "type": "Homework", "drop_count": 2, "weight": 0.15}, {"min_count": 12, "type": "Lab", "drop_count": 2, "weight": 0.15}, {"short_label": "Midterm", "min_count": 1, "type": "Midterm Exam", "drop_count": 0, "weight": 0.3}, {"short_label": "Final", "min_count": 1, "type": "Final Exam", "drop_count": 0, "weight": 0.4}], "GRADE_CUTOFFS": {"Pass": 0.5}}
\ No newline at end of file
{"course/hakj": {"ispublic": false, "graded": false, "tabs": [{"type": "courseware"}, {"type": "course_info", "name": "Course Info"}, {"type": "textbooks"}, {"type": "discussion", "name": "Discussion"}, {"type": "wiki", "name": "Wiki"}, {"type": "progress", "name": "Progress"}], "remote_gradebook": {}, "giturl": null, "discussion_topics": {"General": {"id": "i4x-edx-ctt101-course-html_exception_test"}}, "due": null, "source_file": null, "html_textbooks": [], "announcement": null, "showanswer": "attempted", "display_name": "Principles of Biostatistics", "graceperiod": "900 seconds", "allow_anonymous": false, "tags": [], "enrollment_start": "2013-08-26T04:00:00Z", "start": "2013-08-26T04:00:00Z", "xml_attributes": {"filename": ["course/html_exception_test.xml", "course/html_exception_test.xml"]}, "pdf_textbooks": [], "days_early_for_beta": 100, "advanced_modules": [], "format": null, "xqa_key": "AlQ7TjCl7Rfhc0Am6WguqjeUzGz7AuVt", "enrollment_end": "2013-09-25T04:00:00Z", "end": "2013-12-20T05:00:00Z", "show_calculator": "Yes", "hide_from_toc": false, "rerandomize": "never", "cohort_config": {}}}
\ No newline at end of file
<sequential display_name="Homework 3" due="2013-09-28T04:00:00Z" format="Problem Set" graded="true" start="2013-09-19T21:00:00Z">
<vertical url_name="vertical_74cca8afc761"/>
</sequential>
<vertical display_name="Probability and BMI ">
<customtag href="/static/bio200_hw3_2013_handout.pdf" handout_name="HandoutWeek3ProblemSet.pdf" text_of_link="PDF of Problem Set 3" url_name="customtag_4a3d46019e44">PDF of Problem Set 3</customtag>
</vertical>
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