From b9d79aea605722d177dd3d9b56d2bf23b56ec7f1 Mon Sep 17 00:00:00 2001 From: JonahStanley Date: Thu, 20 Jun 2013 15:55:53 -0400 Subject: [PATCH] A bunch of pylint fixes and explicit use case for uploads/test --- .../contentstore/features/common.py | 25 ++++++++++--------- .../contentstore/features/course-team.py | 16 ++++++------ .../contentstore/features/course-updates.py | 18 ++++++------- .../contentstore/features/static-pages.py | 10 ++++---- .../contentstore/features/upload.py | 16 ++++++------ common/test/data/uploads/test | 2 +- 6 files changed, 44 insertions(+), 43 deletions(-) diff --git a/cms/djangoapps/contentstore/features/common.py b/cms/djangoapps/contentstore/features/common.py index 0b7cb11d2a..e126b746c5 100644 --- a/cms/djangoapps/contentstore/features/common.py +++ b/cms/djangoapps/contentstore/features/common.py @@ -3,7 +3,6 @@ from lettuce import world, step from nose.tools import assert_true -from nose.tools import assert_equal from auth.authz import get_user_by_email @@ -13,12 +12,13 @@ import time from logging import getLogger logger = getLogger(__name__) -COURSE_NAME = 'Robot Super Course' -COURSE_NUM = '999' -COURSE_ORG = 'MITx' +_COURSE_NAME = 'Robot Super Course' +_COURSE_NUM = '999' +_COURSE_ORG = 'MITx' ########### STEP HELPERS ############## + @step('I (?:visit|access|open) the Studio homepage$') def i_visit_the_studio_homepage(_step): # To make this go to port 8001, put @@ -78,10 +78,11 @@ def create_studio_user( registration.register(studio_user) registration.activate() + def fill_in_course_info( - name=COURSE_NAME, - org=COURSE_ORG, - num=COURSE_NUM): + name=_COURSE_NAME, + org=_COURSE_ORG, + num=_COURSE_NUM): world.css_fill('.new-course-name', name) world.css_fill('.new-course-org', org) world.css_fill('.new-course-number', num) @@ -108,14 +109,14 @@ def log_into_studio( def create_a_course(): - c = world.CourseFactory.create(org=COURSE_ORG, course=COURSE_NUM, display_name=COURSE_NAME) + world.CourseFactory.create(org=_COURSE_ORG, course=_COURSE_NUM, display_name=_COURSE_NAME) # Add the user to the instructor group of the course # so they will have the permissions to see it in studio - g = world.GroupFactory.create(name='instructor_MITx/{course_num}/{course_name}'.format(course_num=COURSE_NUM, course_name=COURSE_NAME.replace(" ", "_"))) - u = get_user_by_email('robot+studio@edx.org') - u.groups.add(g) - u.save() + course = world.GroupFactory.create(name='instructor_MITx/{course_num}/{course_name}'.format(course_num=_COURSE_NUM, course_name=_COURSE_NAME.replace(" ", "_"))) + user = get_user_by_email('robot+studio@edx.org') + user.groups.add(course) + user.save() world.browser.reload() course_link_css = 'span.class-name' diff --git a/cms/djangoapps/contentstore/features/course-team.py b/cms/djangoapps/contentstore/features/course-team.py index 439eccb265..15c9e5169d 100644 --- a/cms/djangoapps/contentstore/features/course-team.py +++ b/cms/djangoapps/contentstore/features/course-team.py @@ -9,19 +9,19 @@ EMAIL_EXTENSION = '@edx.org' @step(u'I am viewing the course team settings') -def view_grading_settings(step): +def view_grading_settings(_step): world.click_course_settings() link_css = 'li.nav-course-settings-team a' world.css_click(link_css) @step(u'The user "([^"]*)" exists$') -def create_other_user(step, name): +def create_other_user(_step, name): create_studio_user(uname=name, password=PASSWORD, email=(name + EMAIL_EXTENSION)) @step(u'I add "([^"]*)" to the course team') -def add_other_user(step, name): +def add_other_user(_step, name): new_user_css = 'a.new-user-button' world.css_click(new_user_css) @@ -34,18 +34,18 @@ def add_other_user(step, name): @step(u'I delete "([^"]*)" from the course team') -def delete_other_user(step, name): +def delete_other_user(_step, name): to_delete_css = '.remove-user[data-id="{name}{extension}"]'.format(name=name, extension=EMAIL_EXTENSION) world.css_click(to_delete_css) @step(u'"([^"]*)" logs in$') -def other_user_login(step, name): +def other_user_login(_step, name): log_into_studio(uname=name, password=PASSWORD, email=name + EMAIL_EXTENSION) @step(u'He does( not)? see the course on his page') -def see_course(step, doesnt_see_course): +def see_course(_step, doesnt_see_course): class_css = '.class-name' all_courses = world.css_find(class_css) all_names = [item.html for item in all_courses] @@ -56,12 +56,12 @@ def see_course(step, doesnt_see_course): @step(u'He cannot delete users') -def cannot_delete(step): +def cannot_delete(_step): to_delete_css = '.remove-user' assert world.is_css_not_present(to_delete_css) @step(u'He cannot add users') -def cannot_add(step): +def cannot_add(_step): add_css = '.new-user' assert world.is_css_not_present(add_css) diff --git a/cms/djangoapps/contentstore/features/course-updates.py b/cms/djangoapps/contentstore/features/course-updates.py index 3bbdd75d26..e742b6a40c 100644 --- a/cms/djangoapps/contentstore/features/course-updates.py +++ b/cms/djangoapps/contentstore/features/course-updates.py @@ -7,7 +7,7 @@ from common import type_in_codemirror @step(u'I go to the course updates page') -def go_to_uploads(step): +def go_to_uploads(_step): menu_css = 'li.nav-course-courseware' uploads_css = '.nav-course-courseware-updates' world.css_click(menu_css) @@ -15,14 +15,14 @@ def go_to_uploads(step): @step(u'I add a new update with the text "([^"]*)"$') -def add_update(step, text): +def add_update(_step, text): update_css = '.new-update-button' world.css_click(update_css) change_text(text) @step(u'I should( not)? see the update "([^"]*)"$') -def check_update(step, doesnt_see_update, text): +def check_update(_step, doesnt_see_update, text): update_css = '.update-contents' update = world.css_find(update_css) if doesnt_see_update: @@ -32,20 +32,20 @@ def check_update(step, doesnt_see_update, text): @step(u'I modify the text to "([^"]*)"$') -def modify_update(step, text): +def modify_update(_step, text): button_css = '.post-preview .edit-button' world.css_click(button_css) change_text(text) @step(u'I delete the update$') -def click_button(step): +def click_button(_step): button_css = '.post-preview .delete-button' world.css_click(button_css) @step(u'I edit the date to "([^"]*)"$') -def change_date(step, new_date): +def change_date(_step, new_date): button_css = '.post-preview .edit-button' world.css_click(button_css) date_css = 'input.date' @@ -58,21 +58,21 @@ def change_date(step, new_date): @step(u'I should see the date "([^"]*)"$') -def check_date(step, date): +def check_date(_step, date): date_css = '.date-display' date_html = world.css_find(date_css) assert date == date_html.html @step(u'I modify the handout to "([^"]*)"$') -def edit_handouts(step, text): +def edit_handouts(_step, text): edit_css = '.course-handouts > .edit-button' world.css_click(edit_css) change_text(text) @step(u'I see the handout "([^"]*)"$') -def check_handout(step, handout): +def check_handout(_step, handout): handout_css = '.handouts-content' handouts = world.css_find(handout_css) assert handout in handouts.html diff --git a/cms/djangoapps/contentstore/features/static-pages.py b/cms/djangoapps/contentstore/features/static-pages.py index 56d12f18aa..23656690fc 100644 --- a/cms/djangoapps/contentstore/features/static-pages.py +++ b/cms/djangoapps/contentstore/features/static-pages.py @@ -6,7 +6,7 @@ from selenium.webdriver.common.keys import Keys @step(u'I go to the static pages page') -def go_to_uploads(step): +def go_to_uploads(_step): menu_css = 'li.nav-course-courseware' uploads_css = '.nav-course-courseware-pages' world.css_find(menu_css).click() @@ -14,13 +14,13 @@ def go_to_uploads(step): @step(u'I add a new page') -def add_page(step): +def add_page(_step): button_css = '.new-button' world.css_find(button_css).click() @step(u'I should( not)? see a "([^"]*)" static page$') -def see_page(step, doesnt, page): +def see_page(_step, doesnt, page): index = get_index(page) if doesnt: assert index == -1 @@ -29,7 +29,7 @@ def see_page(step, doesnt, page): @step(u'I "([^"]*)" the "([^"]*)" page$') -def click_edit_delete(step, edit_delete, page): +def click_edit_delete(_step, edit_delete, page): button_css = '.%s-button' % edit_delete index = get_index(page) assert index != -1 @@ -37,7 +37,7 @@ def click_edit_delete(step, edit_delete, page): @step(u'I change the name to "([^"]*)"$') -def change_name(step, new_name): +def change_name(_step, new_name): settings_css = '#settings-mode' world.css_find(settings_css).click() input_css = '.setting-input' diff --git a/cms/djangoapps/contentstore/features/upload.py b/cms/djangoapps/contentstore/features/upload.py index 9b049ccc78..7ef782ea13 100644 --- a/cms/djangoapps/contentstore/features/upload.py +++ b/cms/djangoapps/contentstore/features/upload.py @@ -13,7 +13,7 @@ HTTP_PREFIX = "http://localhost:8001" @step(u'I go to the files and uploads page') -def go_to_uploads(step): +def go_to_uploads(_step): menu_css = 'li.nav-course-courseware' uploads_css = '.nav-course-courseware-uploads' world.css_find(menu_css).click() @@ -21,7 +21,7 @@ def go_to_uploads(step): @step(u'I upload the file "([^"]*)"$') -def upload_file(step, file_name): +def upload_file(_step, file_name): upload_css = '.upload-button' world.css_find(upload_css).click() @@ -36,7 +36,7 @@ def upload_file(step, file_name): @step(u'I should( not)? see the file "([^"]*)" was uploaded$') -def check_upload(step, do_not_see_file, file_name): +def check_upload(_step, do_not_see_file, file_name): index = get_index(file_name) if do_not_see_file: assert index == -1 @@ -45,13 +45,13 @@ def check_upload(step, do_not_see_file, file_name): @step(u'The url for the file "([^"]*)" is valid$') -def check_url(step, file_name): +def check_url(_step, file_name): r = get_file(file_name) assert r.status_code == 200 @step(u'I delete the file "([^"]*)"$') -def delete_file(step, file_name): +def delete_file(_step, file_name): index = get_index(file_name) assert index != -1 delete_css = ".remove-asset-button" @@ -62,7 +62,7 @@ def delete_file(step, file_name): @step(u'I should see only one "([^"]*)"$') -def no_duplicate(step, file_name): +def no_duplicate(_step, file_name): names_css = '.name-col > a.filename' all_names = world.css_find(names_css) only_one = False @@ -73,7 +73,7 @@ def no_duplicate(step, file_name): @step(u'I can download the correct "([^"]*)" file$') -def check_download(step, file_name): +def check_download(_step, file_name): path = os.path.join(TEST_ROOT, 'uploads/', file_name) with open(os.path.abspath(path), 'r') as cur_file: cur_text = cur_file.read() @@ -83,7 +83,7 @@ def check_download(step, file_name): @step(u'I modify "([^"]*)"$') -def modify_upload(step, file_name): +def modify_upload(_step, file_name): new_text = ''.join(random.choice(string.ascii_uppercase + string.digits) for x in range(10)) path = os.path.join(TEST_ROOT, 'uploads/', file_name) with open(os.path.abspath(path), 'w') as cur_file: diff --git a/common/test/data/uploads/test b/common/test/data/uploads/test index 27bb8ecaac..0424951e34 100644 --- a/common/test/data/uploads/test +++ b/common/test/data/uploads/test @@ -1 +1 @@ -R22VMJ2M \ No newline at end of file +This is an arbitrary file for testing uploads