Commit c547ac72 by Sarina Canelake

Fix bulk email acceptance test

parent 1ee6d151
...@@ -44,6 +44,8 @@ def log_in(username='robot', password='test', email='robot@edx.org', name='Robot ...@@ -44,6 +44,8 @@ def log_in(username='robot', password='test', email='robot@edx.org', name='Robot
def register_by_course_id(course_id, username='robot', password='test', is_staff=False): def register_by_course_id(course_id, username='robot', password='test', is_staff=False):
create_user(username, password) create_user(username, password)
user = User.objects.get(username=username) user = User.objects.get(username=username)
# Note: this flag makes the user global staff - that is, an edX employee - not a course staff.
# See courseware.tests.factories for StaffFactory and InstructorFactory.
if is_staff: if is_staff:
user.is_staff = True user.is_staff = True
user.save() user.save()
...@@ -51,18 +53,8 @@ def register_by_course_id(course_id, username='robot', password='test', is_staff ...@@ -51,18 +53,8 @@ def register_by_course_id(course_id, username='robot', password='test', is_staff
@world.absorb @world.absorb
def add_to_course_staff(username, course_num): def enroll_user(user, course_id):
""" CourseEnrollment.enroll(user, course_id)
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 @world.absorb
......
@shard_2 @shard_2
Feature: LMS.Bulk Email Feature: LMS.Instructor Dash Bulk Email
As an instructor or course staff, As an instructor or course staff,
In order to communicate with students and staff In order to communicate with students and staff
I want to send email to staff and students in a course. I want to send email to staff and students in a course.
......
...@@ -11,6 +11,8 @@ from nose.tools import assert_in, assert_true, assert_equal # pylint: disable=E ...@@ -11,6 +11,8 @@ from nose.tools import assert_in, assert_true, assert_equal # pylint: disable=E
from django.core.management import call_command from django.core.management import call_command
from django.conf import settings from django.conf import settings
from courseware.tests.factories import StaffFactory, InstructorFactory
@step(u'Given I am "([^"]*)" for a course') @step(u'Given I am "([^"]*)" for a course')
def i_am_an_instructor(step, role): # pylint: disable=W0613 def i_am_an_instructor(step, role): # pylint: disable=W0613
...@@ -27,47 +29,53 @@ def i_am_an_instructor(step, role): # pylint: disable=W0613 ...@@ -27,47 +29,53 @@ def i_am_an_instructor(step, role): # pylint: disable=W0613
number='999', number='999',
display_name='Test Course' display_name='Test Course'
) )
world.course_id = 'edx/999/Test_Course'
# Register the instructor as staff for the course try:
world.register_by_course_id( # See if we've defined the instructor & staff user yet
'edx/999/Test_Course', world.instructor
username='instructor', except AttributeError:
password='password', # Make & register an instructor for the course
is_staff=True world.instructor = InstructorFactory(course=course.location)
) world.enroll_user(world.instructor, world.course_id)
world.add_to_course_staff('instructor', '999')
# Register another staff member # Make & register a staff member
world.register_by_course_id( world.staff = StaffFactory(course=course.location)
'edx/999/Test_Course', world.enroll_user(world.staff, world.course_id)
username='staff',
password='password',
is_staff=True
)
world.add_to_course_staff('staff', '999')
# Register a student # Make & register a student
world.register_by_course_id( world.register_by_course_id(
'edx/999/Test_Course', 'edx/999/Test_Course',
username='student', username='student',
password='password', password='test',
is_staff=False is_staff=False
) )
# Log in as the an instructor or staff for the course # Log in as the an instructor or staff for the course
world.log_in( my_email = None
username=role, if role == 'instructor':
password='password', my_email = world.instructor.email
email="instructor@edx.org", world.log_in(
name="Instructor" username=world.instructor.username,
) password='test',
email=my_email,
name=world.instructor.profile.name
)
else:
my_email = world.staff.email
world.log_in(
username=world.staff.username,
password='test',
email=world.staff.email,
name=world.staff.profile.name
)
# Store the expected recipients # Store the expected recipients
# given each "send to" option # given each "send to" option
world.expected_addresses = { world.expected_addresses = {
'myself': [role + '@edx.org'], 'myself': [my_email],
'course staff': ['instructor@edx.org', 'staff@edx.org'], 'course staff': [world.staff.email, world.instructor.email],
'students, staff, and instructors': ['instructor@edx.org', 'staff@edx.org', 'student@edx.org'] 'students, staff, and instructors': [world.staff.email, world.instructor.email, 'student@edx.org']
} }
...@@ -131,7 +139,6 @@ UNSUBSCRIBE_MSG = 'To stop receiving email like this' ...@@ -131,7 +139,6 @@ UNSUBSCRIBE_MSG = 'To stop receiving email like this'
@step(u'Email is sent to "([^"]*)"') @step(u'Email is sent to "([^"]*)"')
def then_the_email_is_sent(step, recipient): def then_the_email_is_sent(step, recipient):
# Check that the recipient is valid # Check that the recipient is valid
assert_in( assert_in(
recipient, SEND_TO_OPTIONS, recipient, SEND_TO_OPTIONS,
......
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