""" 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 # pylint: disable=E0611 from django.core.management import call_command from django.conf import settings @step(u'Given I am "([^"]*)" for a course') def i_am_an_instructor(step, role): # pylint: disable=W0613 # Store the role assert_in(role, ['instructor', 'staff']) # 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', username='instructor', password='password', is_staff=True ) world.add_to_course_staff('instructor', '999') # 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') # Register a student world.register_by_course_id( 'edx/999/Test_Course', username='student', password='password', 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" ) # 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'] } # Dictionary mapping a description of the email recipient # to the corresponding