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
def register_by_course_id(course_id, username='robot', password='test', is_staff=False):
create_user(username, password)
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:
user.is_staff = True
user.save()
......@@ -51,18 +53,8 @@ def register_by_course_id(course_id, username='robot', password='test', is_staff
@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)
def enroll_user(user, course_id):
CourseEnrollment.enroll(user, course_id)
@world.absorb
......
@shard_2
Feature: LMS.Bulk Email
Feature: LMS.Instructor Dash Bulk Email
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.
......
......@@ -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.conf import settings
from courseware.tests.factories import StaffFactory, InstructorFactory
@step(u'Given I am "([^"]*)" for a course')
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',
display_name='Test Course'
)
world.course_id = 'edx/999/Test_Course'
# Register the instructor as staff for the course
world.register_by_course_id(
'edx/999/Test_Course',
username='instructor',
password='password',
is_staff=True
)
world.add_to_course_staff('instructor', '999')
try:
# See if we've defined the instructor & staff user yet
world.instructor
except AttributeError:
# Make & register an instructor for the course
world.instructor = InstructorFactory(course=course.location)
world.enroll_user(world.instructor, world.course_id)
# Register another staff member
world.register_by_course_id(
'edx/999/Test_Course',
username='staff',
password='password',
is_staff=True
)
world.add_to_course_staff('staff', '999')
# Make & register a staff member
world.staff = StaffFactory(course=course.location)
world.enroll_user(world.staff, world.course_id)
# Register a student
# Make & register a student
world.register_by_course_id(
'edx/999/Test_Course',
username='student',
password='password',
password='test',
is_staff=False
)
# Log in as the an instructor or staff for the course
world.log_in(
username=role,
password='password',
email="instructor@edx.org",
name="Instructor"
)
my_email = None
if role == 'instructor':
my_email = world.instructor.email
world.log_in(
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
# given each "send to" option
world.expected_addresses = {
'myself': [role + '@edx.org'],
'course staff': ['instructor@edx.org', 'staff@edx.org'],
'students, staff, and instructors': ['instructor@edx.org', 'staff@edx.org', 'student@edx.org']
'myself': [my_email],
'course staff': [world.staff.email, world.instructor.email],
'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'
@step(u'Email is sent to "([^"]*)"')
def then_the_email_is_sent(step, recipient):
# Check that the recipient is valid
assert_in(
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