From ccc8b599f11a48c544f01c641164ae73a7b0f04e Mon Sep 17 00:00:00 2001 From: Jay Zoldak Date: Fri, 14 Dec 2012 17:16:29 -0500 Subject: [PATCH] Fixed tests to work OK so far. --- .../courseware/features/course_info.feature | 19 -------- .../courseware/features/course_info.py | 14 ------ lms/djangoapps/portal/features/common.py | 47 ++++--------------- .../portal/features/registration.feature | 3 +- lms/djangoapps/terrain/common.py | 5 +- 5 files changed, 10 insertions(+), 78 deletions(-) delete mode 100644 lms/djangoapps/courseware/features/course_info.feature delete mode 100644 lms/djangoapps/courseware/features/course_info.py diff --git a/lms/djangoapps/courseware/features/course_info.feature b/lms/djangoapps/courseware/features/course_info.feature deleted file mode 100644 index f58dc9c5cc..0000000000 --- a/lms/djangoapps/courseware/features/course_info.feature +++ /dev/null @@ -1,19 +0,0 @@ -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 diff --git a/lms/djangoapps/courseware/features/course_info.py b/lms/djangoapps/courseware/features/course_info.py deleted file mode 100644 index 60cd91cd88..0000000000 --- a/lms/djangoapps/courseware/features/course_info.py +++ /dev/null @@ -1,14 +0,0 @@ -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) diff --git a/lms/djangoapps/portal/features/common.py b/lms/djangoapps/portal/features/common.py index 553f0da0a1..2f379acaa4 100644 --- a/lms/djangoapps/portal/features/common.py +++ b/lms/djangoapps/portal/features/common.py @@ -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) diff --git a/lms/djangoapps/portal/features/registration.feature b/lms/djangoapps/portal/features/registration.feature index ad226c479b..d8a6796ee3 100644 --- a/lms/djangoapps/portal/features/registration.feature +++ b/lms/djangoapps/portal/features/registration.feature @@ -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 diff --git a/lms/djangoapps/terrain/common.py b/lms/djangoapps/terrain/common.py index 36de93debc..bd95edb65d 100644 --- a/lms/djangoapps/terrain/common.py +++ b/lms/djangoapps/terrain/common.py @@ -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)