Commit b3946828 by Will Daly

Added lettuce tests for string problems

parent e6466fdd
...@@ -13,6 +13,7 @@ Feature: Answer choice problems ...@@ -13,6 +13,7 @@ Feature: Answer choice problems
| drop down | | drop down |
| multiple choice | | multiple choice |
| checkbox | | checkbox |
| string |
Scenario: I can answer a problem incorrectly Scenario: I can answer a problem incorrectly
Given I am viewing a "<ProblemType>" problem Given I am viewing a "<ProblemType>" problem
...@@ -24,6 +25,7 @@ Feature: Answer choice problems ...@@ -24,6 +25,7 @@ Feature: Answer choice problems
| drop down | | drop down |
| multiple choice | | multiple choice |
| checkbox | | checkbox |
| string |
Scenario: I can submit a blank answer Scenario: I can submit a blank answer
Given I am viewing a "<ProblemType>" problem Given I am viewing a "<ProblemType>" problem
...@@ -35,6 +37,7 @@ Feature: Answer choice problems ...@@ -35,6 +37,7 @@ Feature: Answer choice problems
| drop down | | drop down |
| multiple choice | | multiple choice |
| checkbox | | checkbox |
| string |
Scenario: I can reset a problem Scenario: I can reset a problem
...@@ -51,3 +54,5 @@ Feature: Answer choice problems ...@@ -51,3 +54,5 @@ Feature: Answer choice problems
| multiple choice | incorrect | | multiple choice | incorrect |
| checkbox | correct | | checkbox | correct |
| checkbox | incorrect | | checkbox | incorrect |
| string | correct |
| string | incorrect |
...@@ -5,7 +5,8 @@ from common import i_am_registered_for_the_course ...@@ -5,7 +5,8 @@ from common import i_am_registered_for_the_course
problem_urls = { 'drop down': '/courses/edX/model_course/2013_Spring/courseware/Problem_Components/Drop_Down_Problems', problem_urls = { 'drop down': '/courses/edX/model_course/2013_Spring/courseware/Problem_Components/Drop_Down_Problems',
'multiple choice': '/courses/edX/model_course/2013_Spring/courseware/Problem_Components/Multiple_Choice_Problems', 'multiple choice': '/courses/edX/model_course/2013_Spring/courseware/Problem_Components/Multiple_Choice_Problems',
'checkbox': '/courses/edX/model_course/2013_Spring/courseware/Problem_Components/Checkbox_Problems', } 'checkbox': '/courses/edX/model_course/2013_Spring/courseware/Problem_Components/Checkbox_Problems',
'string': '/courses/edX/model_course/2013_Spring/courseware/Problem_Components/String_Problems' }
@step(u'I am viewing a "([^"]*)" problem') @step(u'I am viewing a "([^"]*)" problem')
def view_problem(step, problem_type): def view_problem(step, problem_type):
...@@ -35,6 +36,11 @@ def answer_problem(step, problem_type, correctness): ...@@ -35,6 +36,11 @@ def answer_problem(step, problem_type, correctness):
else: else:
world.browser.find_by_css('#input_i4x-edX-model_course-problem-Checkbox_Problem_2_1_choice_3').check() world.browser.find_by_css('#input_i4x-edX-model_course-problem-Checkbox_Problem_2_1_choice_3').check()
elif problem_type == 'string':
textfield = world.browser.find_by_css("input#input_i4x-edX-model_course-problem-String_Problem_2_1")
textvalue = 'correct string' if correctness == 'correct' else 'incorrect'
textfield.fill(textvalue)
check_problem(step) check_problem(step)
@step(u'I check a problem') @step(u'I check a problem')
...@@ -65,10 +71,18 @@ def assert_answer_mark(step, problem_type, correctness): ...@@ -65,10 +71,18 @@ def assert_answer_mark(step, problem_type, correctness):
# Two ways to be marked incorrect: either applying a # Two ways to be marked incorrect: either applying a
# class to the label (marking a particular option) # class to the label (marking a particular option)
# or applying a class to a span (marking the whole problem incorrect) # or applying a class to a span (marking the whole problem incorrect)
mark_classes = ['label.choicegroup_incorrect', 'label.incorrect'] mark_classes = ['label.choicegroup_incorrect', 'span.incorrect']
assert(world.browser.is_element_present_by_css(mark_classes[0], wait_time=4) or assert(world.browser.is_element_present_by_css(mark_classes[0], wait_time=4) or
world.browser.is_element_present_by_css(mark_classes[1], wait_time=4)) world.browser.is_element_present_by_css(mark_classes[1], wait_time=4))
elif problem_type == "string":
if correctness == 'unanswered':
assert(world.browser.is_element_not_present_by_css('div.correct'))
assert(world.browser.is_element_not_present_by_css('div.incorrect'))
else:
mark_class = 'div.correct' if correctness == 'correct' else 'div.incorrect'
assert(world.browser.is_element_present_by_css(mark_class, wait_time=4))
else: else:
if correctness == 'unanswered': if correctness == 'unanswered':
assert(world.browser.is_element_not_present_by_css('span.correct')) assert(world.browser.is_element_not_present_by_css('span.correct'))
......
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