Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jonahstanley/add more tests #10

Merged
merged 12 commits into from
Jun 3, 2013
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,4 @@ Giulio Gratta <giulio@giuliogratta.com>
David Baumgold <david@davidbaumgold.com>
Jason Bau <jbau@stanford.edu>
Frances Botsford <frances@edx.org>
Jonah Stanley <Jonah_Stanley@brown.edu>
6 changes: 0 additions & 6 deletions cms/djangoapps/contentstore/features/courses.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,6 @@ def i_see_the_course_in_my_courses(step):
assert world.css_has_text(course_css, 'Robot Super Course')


@step('the course is loaded$')
def course_is_loaded(step):
class_css = 'a.class-name'
assert world.css_has_text(course_css, 'Robot Super Cousre')


@step('I am on the "([^"]*)" tab$')
def i_am_on_tab(step, tab_name):
header_css = 'div.inner-wrapper h1'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def all_sections_are_expanded(step):


@step(u'all sections are collapsed$')
def all_sections_are_expanded(step):
def all_sections_are_collapsed(step):
subsection_locator = 'div.subsection-list'
subsections = world.css_find(subsection_locator)
for s in subsections:
Expand Down
1 change: 0 additions & 1 deletion lms/djangoapps/courseware/features/courseware_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ def i_click_on_view_courseware(step):
@step('I click on the "([^"]*)" tab$')
def i_click_on_the_tab(step, tab_text):
world.click_link(tab_text)
world.save_the_html()


@step('I visit the courseware URL$')
Expand Down
5 changes: 1 addition & 4 deletions lms/djangoapps/courseware/features/high-level-tabs.feature
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ Scenario: I can navigate to all high - level tabs in a course
And The course "6.002x" has extra tab "Custom Tab"
And I am logged in
And I click on View Courseware
When I click on the "<TabName>" tab
Then the page title should contain "<PageTitle>"

Examples:
When I click on the tabs then the page title should contain the following titles:
| TabName | PageTitle |
| Courseware | 6.002x Courseware |
| Course Info | 6.002x Course Info |
Expand Down
11 changes: 11 additions & 0 deletions lms/djangoapps/courseware/features/high-level-tabs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from lettuce import world, step
from nose.tools import assert_equals


@step(u'I click on the tabs then the page title should contain the following titles:')
def i_click_on_the_tab_and_check(step):
for tab_title in step.hashes:
tab_text = tab_title['TabName']
title = tab_title['PageTitle']
world.click_link(tab_text)
assert(title in world.browser.title)
8 changes: 2 additions & 6 deletions lms/djangoapps/courseware/features/homepage.feature
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ Feature: Homepage for web users

Scenario Outline: User can see main parts of the page
Given I visit the homepage
Then I should see a link with the id "<id>" called "<Link>"

Examples:
Then I should see the following links and ids
| id | Link |
| about | About |
| jobs | Jobs |
Expand All @@ -27,9 +25,7 @@ Feature: Homepage for web users
# TODO: test according to domain or policy
Scenario: User can see the partner institutions
Given I visit the homepage
Then I should see "<Partner>" in the Partners section

Examples:
Then I should see the following Partners in the Partners section
| Partner |
| MITx |
| HarvardX |
Expand Down
19 changes: 15 additions & 4 deletions lms/djangoapps/courseware/features/homepage.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,22 @@
#pylint: disable=W0621

from lettuce import world, step
from nose.tools import assert_in
from nose.tools import assert_in, assert_equals


@step('I should see "([^"]*)" in the Partners section$')
def i_should_see_partner(step, partner):
@step(u'I should see the following Partners in the Partners section')
def i_should_see_partner(step):
partners = world.browser.find_by_css(".partner .name span")
names = set(span.text for span in partners)
assert_in(partner, names)
for partner in step.hashes:
assert_in(partner['Partner'], names)


@step(u'I should see the following links and ids')
def should_see_a_link_called(step):
for link_id_pair in step.hashes:
link_id = link_id_pair['id']
text = link_id_pair['Link']
link = world.browser.find_by_id(link_id)
assert len(link) > 0
assert_equals(link.text, text)
55 changes: 55 additions & 0 deletions lms/djangoapps/courseware/features/problems.feature
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,58 @@ Feature: Answer problems
| formula | incorrect |
| script | correct |
| script | incorrect |


Scenario: I can answer a problem with one attempt correctly
Given I am viewing a "multiple choice" problem with "1" attempt
Then I should see "You have used 0 of 1 submissions" somewhere in the page
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assertions should be on outcomes. We are following the Given-When-Then pattern.
Move "you have used x of y submissions" and "final check" button from the tests an make it a separate test that will pass/fail discreetly.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. You can also remove the assertions for checking that a problem is marked correct/incorrect because other test cases cover this logic.

And The "Final Check" button does appear
When I answer a "multiple choice" problem "correctly"
Then My "multiple choice" answer is marked "correct"
And The "multiple choice" problem displays a "correct" answer
And The "Reset" button does not appear

Scenario: I can answer a problem with one attempt incorrectly
Given I am viewing a "multiple choice" problem with "1" attempt
When I answer a "multiple choice" problem "incorrectly"
Then My "multiple choice" answer is marked "incorrect"
And The "multiple choice" problem displays a "incorrect" answer
And The "Reset" button does not appear

Scenario: I can answer a problem with multiple attempts correctly
Given I am viewing a "multiple choice" problem with "3" attempts
Then I should see "You have used 0 of 3 submissions" somewhere in the page
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These scenarios should be rewritten to follow the Given-When-Then convention. It seems like what you are trying to test here should be broken out so that a test will fail discreetly if the functionality is broken.
Let's get this PR merged in first, then refactor.

When I answer a "multiple choice" problem "correctly"
Then My "multiple choice" answer is marked "correct"
And The "multiple choice" problem displays a "correct" answer
And The "Reset" button does appear

Scenario: I can answer a problem with multiple attempts correctly on final guess
Given I am viewing a "multiple choice" problem with "3" attempts
Then I should see "You have used 0 of 3 submissions" somewhere in the page
When I answer a "multiple choice" problem "incorrectly"
Then My "multiple choice" answer is marked "incorrect"
And The "multiple choice" problem displays a "incorrect" answer
When I reset the problem
Then I should see "You have used 1 of 3 submissions" somewhere in the page
When I answer a "multiple choice" problem "incorrectly"
Then My "multiple choice" answer is marked "incorrect"
And The "multiple choice" problem displays a "incorrect" answer
When I reset the problem
Then I should see "You have used 2 of 3 submissions" somewhere in the page
And The "Final Check" button does appear
When I answer a "multiple choice" problem "correctly"
Then My "multiple choice" answer is marked "correct"
And The "multiple choice" problem displays a "correct" answer
And The "Reset" button does not appear

Scenario: I can view and hide the answer if the problem has it:
Given I am viewing a "numerical" that shows the answer "always"
Then The "Show Answer" button does appear
When I press the "Show Answer" button
Then The "Hide Answer" button does appear
And The "Show Answer" button does not appear
And I should see "4.14159" somewhere in the page
When I press the "Hide Answer" button
Then The "Show Answer" button does appear
And I do not see "4.14159" anywhere on the page
Loading