Commit ccc8b599 by Jay Zoldak

Fixed tests to work OK so far.

parent 7e5a67ba
Feature: View the Course Info tab
As a student in an edX course
In order to get background on the course
I want to view the info on the course info tab
Scenario: I can get to the course info tab when logged in
Given I am logged in
And I am registered for a course
And I visit the dashboard
When I click on View Courseware
Then I am on an info page
And the Course Info tab is active
And I do not see "! Info section missing !" anywhere on the page
Scenario: I cannot get to the course info tab when not logged in
Given I am not logged in
And I visit the homepage
When I visit the course info URL
Then the login dialog is visible
from lettuce import world, step
from lettuce.django import django_url
@step('I am on an info page')
def i_am_on_an_info_page(step):
title = world.browser.title
url = world.browser.url
assert ('Course Info' in title)
assert (r'/info' in url)
@step('I visit the course info URL$')
def i_visit_the_course_info_url(step):
url = django_url('/courses/MITx/6.002x/2012_Fall/info')
world.browser.visit(url)
......@@ -45,21 +45,8 @@ def the_page_title_should_be(step, title):
@step('I am logged in$')
def i_am_logged_in(step):
# This is a workaround for now, until askbot is removed
# because askbot is messing with the user and auth tables.
call_command('loaddata', '/tmp/fixtures/robot_user_active.json')
world.browser.cookies.delete()
world.browser.visit(django_url('/'))
world.browser.is_element_present_by_css('header.global', 10)
world.browser.click_link_by_href('#login-modal')
login_form = world.browser.find_by_css('form#login_form')
login_form.find_by_name('email').fill('robot@edx.org')
login_form.find_by_name('password').fill('test')
login_form.find_by_name('submit').click()
# wait for the page to redraw
assert world.browser.is_element_present_by_css('.content-wrapper', 5)
world.create_user('robot')
world.log_in('robot@edx.org', 'test')
@step('I am not logged in$')
def i_am_not_logged_in(step):
......@@ -67,33 +54,15 @@ def i_am_not_logged_in(step):
@step(u'I am registered for a course$')
def i_am_registered_for_a_course(step):
u = User.objects.get(username='robot2')
world.create_user('robot')
u = User.objects.get(username='robot')
CourseEnrollment.objects.create(user=u, course_id='MITx/6.002x/2012_Fall')
world.log_in('robot@edx.org', 'test')
@step(u'I am an edX user$')
def i_am_an_edx_user(step):
call_command('loaddata', '/tmp/fixtures/robot_user_active.json')
world.create_user('robot')
########### USER CREATION ##############
@step(u'User "([^"]*)" is an edX user$')
def registered_edx_user(step, uname):
# This user factory stuff should work after we kill askbot
# portal_user = UserFactory.build(username=uname, email=uname + '@edx.org')
# portal_user.set_password('test')
# portal_user.save()
# registration = RegistrationFactory(user=portal_user)
# registration.register(portal_user)
# registration.activate()
# user_profile = UserProfileFactory(user=portal_user)
# This is a workaround for now, until askbot is removed
# because askbot is messing with the user and auth tables.
call_command('loaddata', '/tmp/fixtures/robot_user_active.json')
########### DEBUGGING ##############
@step(u'I save a screenshot to "(.*)"')
def save_screenshot_to(step, filename):
world.browser.driver.save_screenshot(filename)
world.create_user(uname)
......@@ -10,8 +10,7 @@ Feature: Register for a course
Then I should see the course numbered "6.002x" in my dashboard
Scenario: I can unregister for a course
Given I am logged in
And I am registered for a course
Given I am registered for a course
And I visit the dashboard
When I click the link with the text "Unregister"
And I press the "Unregister" button in the Unenroll dialog
......
......@@ -85,6 +85,7 @@ def i_am_an_edx_user(step):
create_user('robot')
#### helper functions
@world.absorb
def create_user(uname):
# This user factory stuff should work after we kill askbot
portal_user = UserFactory.build(username=uname, email=uname + '@edx.org')
......@@ -171,7 +172,3 @@ def save_the_course_content(path='/tmp'):
f.write(output)
f.close
########### DEBUGGING ##############
@step(u'I save a screenshot to "(.*)"')
def save_screenshot_to(step, filename):
world.browser.driver.save_screenshot(filename)
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