From 8a30e9ba8f5e484e4257a69035b20342a41520c7 Mon Sep 17 00:00:00 2001 From: Julia Hansbrough Date: Mon, 7 Oct 2013 17:59:58 +0000 Subject: [PATCH] Legacy email tests, removed duplicate code, updated comments, fixed CSS --- common/djangoapps/terrain/course_helpers.py | 13 -- common/djangoapps/terrain/ui_helpers.py | 17 +++ .../instructor/features/bulk_email.feature | 16 +- .../instructor/features/bulk_email.py | 39 +++-- lms/djangoapps/instructor/tests/test_api.py | 131 +++------------- lms/djangoapps/instructor/tests/test_email.py | 102 +++++-------- .../instructor/tests/test_legacy_email.py | 142 ++++++++++++++++++ lms/djangoapps/instructor/views/api.py | 62 ++------ .../instructor/views/instructor_dashboard.py | 9 +- lms/envs/acceptance.py | 10 +- lms/envs/common.py | 2 +- .../instructor_dashboard/send_email.coffee | 22 ++- .../sass/course/instructor/_instructor_2.scss | 52 +------ .../courseware/instructor_dashboard.html | 2 +- .../instructor_dashboard_2/send_email.html | 5 +- 15 files changed, 303 insertions(+), 321 deletions(-) create mode 100644 lms/djangoapps/instructor/tests/test_legacy_email.py diff --git a/common/djangoapps/terrain/course_helpers.py b/common/djangoapps/terrain/course_helpers.py index 1b7cbb71f0..26a60ef994 100644 --- a/common/djangoapps/terrain/course_helpers.py +++ b/common/djangoapps/terrain/course_helpers.py @@ -49,19 +49,6 @@ def register_by_course_id(course_id, username='robot', password='test', is_staff u.save() CourseEnrollment.enroll(u, course_id) -@world.absorb -def add_to_course_staff(username, course_num): - """ - Add the user with `username` to the course staff group - for `course_num`. - """ - # Based on code in lms/djangoapps/courseware/access.py - group_name = "instructor_{}".format(course_num) - group, _ = Group.objects.get_or_create(name=group_name) - group.save() - - user = User.objects.get(username=username) - user.groups.add(group) @world.absorb def add_to_course_staff(username, course_num): diff --git a/common/djangoapps/terrain/ui_helpers.py b/common/djangoapps/terrain/ui_helpers.py index f143973c46..52ab7462a5 100644 --- a/common/djangoapps/terrain/ui_helpers.py +++ b/common/djangoapps/terrain/ui_helpers.py @@ -70,6 +70,23 @@ def css_has_text(css_selector, text, index=0, strip=False): return actual_text == text +@world.absorb +def css_has_value(css_selector, value, index=0): + """ + Return a boolean indicating whether the element with + `css_selector` has the specified `value`. + + If there are multiple elements matching the css selector, + use `index` to indicate which one. + """ + # If we're expecting a non-empty string, give the page + # a chance to fill in values + if value: + world.wait_for(lambda _: world.css_value(css_selector, index=index)) + + return world.css_value(css_selector, index=index) == value + + @world.absorb def wait_for(func, timeout=5): WebDriverWait( diff --git a/lms/djangoapps/instructor/features/bulk_email.feature b/lms/djangoapps/instructor/features/bulk_email.feature index 7b46d1ec9b..8d3784c1ea 100644 --- a/lms/djangoapps/instructor/features/bulk_email.feature +++ b/lms/djangoapps/instructor/features/bulk_email.feature @@ -1,16 +1,20 @@ @shard_2 Feature: Bulk Email - As an instructor, + As an instructor or course staff, In order to communicate with students and staff I want to send email to staff and students in a course. Scenario: Send bulk email - Given I am an instructor for a course + Given I am "" for a course When I send email to "" Then Email is sent to "" Examples: - | Recipient | - | myself | - | course staff | - | students, staff, and instructors | + | Role | Recipient | + | instructor | myself | + | instructor | course staff | + | instructor | students, staff, and instructors | + | staff | myself | + | staff | course staff | + | staff | students, staff, and instructors | + diff --git a/lms/djangoapps/instructor/features/bulk_email.py b/lms/djangoapps/instructor/features/bulk_email.py index 6706f0f430..220ab9ecee 100644 --- a/lms/djangoapps/instructor/features/bulk_email.py +++ b/lms/djangoapps/instructor/features/bulk_email.py @@ -2,25 +2,22 @@ Define steps for bulk email acceptance test. """ +#pylint: disable=C0111 +#pylint: disable=W0621 + from lettuce import world, step from lettuce.django import mail -from nose.tools import assert_in, assert_true, assert_equal +from nose.tools import assert_in, assert_true, assert_equal # pylint: disable=E0611 from django.core.management import call_command +from django.conf import settings @step(u'I am an instructor for a course') -def i_am_an_instructor(step): +def i_am_an_instructor(step): # pylint: disable=W0613 # Clear existing courses to avoid conflicts world.clear_courses() - # Create a new course - course = world.CourseFactory.create( - org='edx', - number='999', - display_name='Test Course' - ) - # Register the instructor as staff for the course world.register_by_course_id( 'edx/999/Test_Course', @@ -59,14 +56,14 @@ def i_am_an_instructor(step): # Dictionary mapping a description of the email recipient # to the corresponding