From 5a2a4055f8bb84fff9bf53888e8b23423f7d6703 Mon Sep 17 00:00:00 2001 From: Will Daly Date: Wed, 13 Mar 2013 17:18:02 -0400 Subject: [PATCH] Added lettuce test for formula problem --- lms/djangoapps/courseware/features/problems.feature | 5 +++++ lms/djangoapps/courseware/features/problems.py | 10 ++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/lms/djangoapps/courseware/features/problems.feature b/lms/djangoapps/courseware/features/problems.feature index a1e4712f6a..12458537d0 100644 --- a/lms/djangoapps/courseware/features/problems.feature +++ b/lms/djangoapps/courseware/features/problems.feature @@ -15,6 +15,7 @@ Feature: Answer choice problems | checkbox | | string | | numerical | + | formula | Scenario: I can answer a problem incorrectly Given I am viewing a "" problem @@ -28,6 +29,7 @@ Feature: Answer choice problems | checkbox | | string | | numerical | + | formula | Scenario: I can submit a blank answer Given I am viewing a "" problem @@ -41,6 +43,7 @@ Feature: Answer choice problems | checkbox | | string | | numerical | + | formula | Scenario: I can reset a problem @@ -61,3 +64,5 @@ Feature: Answer choice problems | string | incorrect | | numerical | correct | | numerical | incorrect | + | formula | correct | + | formula | incorrect | diff --git a/lms/djangoapps/courseware/features/problems.py b/lms/djangoapps/courseware/features/problems.py index 666182684c..c1b634783d 100644 --- a/lms/djangoapps/courseware/features/problems.py +++ b/lms/djangoapps/courseware/features/problems.py @@ -8,7 +8,8 @@ problem_urls = { 'drop down': '/courses/edX/model_course/2013_Spring/courseware/ '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', - 'numerical': '/courses/edX/model_course/2013_Spring/courseware/Problem_Components/Numerical_Problems', } + 'numerical': '/courses/edX/model_course/2013_Spring/courseware/Problem_Components/Numerical_Problems', + 'formula': '/courses/edX/model_course/2013_Spring/courseware/Problem_Components/Formula_Problems', } @step(u'I am viewing a "([^"]*)" problem') def view_problem(step, problem_type): @@ -48,6 +49,11 @@ def answer_problem(step, problem_type, correctness): textvalue = "pi + 1" if correctness == 'correct' else str(random.randint(-2,2)) textfield.fill(textvalue) + elif problem_type == 'formula': + textfield = world.browser.find_by_css("input#input_i4x-edX-model_course-problem-Formula_Problem_2_1") + textvalue = "x^2+2*x+y" if correctness == 'correct' else 'x^2' + textfield.fill(textvalue) + check_problem(step) @step(u'I check a problem') @@ -82,7 +88,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 in ["string", "numerical"]: + elif problem_type in ["string", "numerical", "formula"]: 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'))