Added lettuce tests for numerical problem
This commit is contained in:
@@ -14,6 +14,7 @@ Feature: Answer choice problems
|
||||
| multiple choice |
|
||||
| checkbox |
|
||||
| string |
|
||||
| numerical |
|
||||
|
||||
Scenario: I can answer a problem incorrectly
|
||||
Given I am viewing a "<ProblemType>" problem
|
||||
@@ -26,6 +27,7 @@ Feature: Answer choice problems
|
||||
| multiple choice |
|
||||
| checkbox |
|
||||
| string |
|
||||
| numerical |
|
||||
|
||||
Scenario: I can submit a blank answer
|
||||
Given I am viewing a "<ProblemType>" problem
|
||||
@@ -38,6 +40,7 @@ Feature: Answer choice problems
|
||||
| multiple choice |
|
||||
| checkbox |
|
||||
| string |
|
||||
| numerical |
|
||||
|
||||
|
||||
Scenario: I can reset a problem
|
||||
@@ -56,3 +59,5 @@ Feature: Answer choice problems
|
||||
| checkbox | incorrect |
|
||||
| string | correct |
|
||||
| string | incorrect |
|
||||
| numerical | correct |
|
||||
| numerical | incorrect |
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
from lettuce import world, step
|
||||
from lettuce.django import django_url
|
||||
from selenium.webdriver.support.ui import Select
|
||||
import random
|
||||
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',
|
||||
'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',
|
||||
'string': '/courses/edX/model_course/2013_Spring/courseware/Problem_Components/String_Problems' }
|
||||
'string': '/courses/edX/model_course/2013_Spring/courseware/Problem_Components/String_Problems',
|
||||
'numerical': '/courses/edX/model_course/2013_Spring/courseware/Problem_Components/Numerical_Problems', }
|
||||
|
||||
@step(u'I am viewing a "([^"]*)" problem')
|
||||
def view_problem(step, problem_type):
|
||||
@@ -25,22 +27,27 @@ def answer_problem(step, problem_type, correctness):
|
||||
|
||||
elif problem_type == "multiple choice":
|
||||
if correctness == 'correct':
|
||||
world.browser.find_by_css("#input_i4x-edX-model_course-problem-Multiple_Choice_Problem_2_1_choice_choice_3").check()
|
||||
world.browser.find_by_css("input#input_i4x-edX-model_course-problem-Multiple_Choice_Problem_2_1_choice_choice_3").check()
|
||||
else:
|
||||
world.browser.find_by_css("#input_i4x-edX-model_course-problem-Multiple_Choice_Problem_2_1_choice_choice_2").check()
|
||||
world.browser.find_by_css("input#input_i4x-edX-model_course-problem-Multiple_Choice_Problem_2_1_choice_choice_2").check()
|
||||
|
||||
elif problem_type == "checkbox":
|
||||
if correctness == 'correct':
|
||||
world.browser.find_by_css('#input_i4x-edX-model_course-problem-Checkbox_Problem_2_1_choice_0').check()
|
||||
world.browser.find_by_css('#input_i4x-edX-model_course-problem-Checkbox_Problem_2_1_choice_2').check()
|
||||
world.browser.find_by_css('input#input_i4x-edX-model_course-problem-Checkbox_Problem_2_1_choice_0').check()
|
||||
world.browser.find_by_css('input#input_i4x-edX-model_course-problem-Checkbox_Problem_2_1_choice_2').check()
|
||||
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#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)
|
||||
|
||||
elif problem_type == 'numerical':
|
||||
textfield = world.browser.find_by_css("input#input_i4x-edX-model_course-problem-Numerical_Problem_2_1")
|
||||
textvalue = "pi + 1" if correctness == 'correct' else str(random.randint(-2,2))
|
||||
textfield.fill(textvalue)
|
||||
|
||||
check_problem(step)
|
||||
|
||||
@step(u'I check a problem')
|
||||
@@ -75,7 +82,7 @@ def assert_answer_mark(step, problem_type, correctness):
|
||||
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))
|
||||
|
||||
elif problem_type == "string":
|
||||
elif problem_type in ["string", "numerical"]:
|
||||
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'))
|
||||
|
||||
Reference in New Issue
Block a user