def setUp(self): """ Initialize the test. Create the necessary page objects, create course page and courses to find. """ super(RegisterCourseTests, self).setUp() # create test file in which index for this test will live with open(self.TEST_INDEX_FILENAME, "w+") as index_file: json.dump({}, index_file) self.addCleanup(remove_file, self.TEST_INDEX_FILENAME) self.course_discovery = CourseDiscoveryPage(self.browser) self.dashboard_page = DashboardPage(self.browser) self.course_about = CourseAboutPage(self.browser, self.course_id) # Create a course CourseFixture(self.course_info['org'], self.course_info['number'], self.course_info['run'], self.course_info['display_name'], settings={ 'enrollment_start': datetime(1970, 1, 1).isoformat() }).install() # Create a user and log them in AutoAuthPage(self.browser).visit()
class RegisterCourseTests(EventsTestMixin, UniqueCourseTest): """Test that learner can enroll into a course from courses page""" TEST_INDEX_FILENAME = "test_root/index_file.dat" def setUp(self): """ Initialize the test. Create the necessary page objects, create course page and courses to find. """ super(RegisterCourseTests, self).setUp() # create test file in which index for this test will live with open(self.TEST_INDEX_FILENAME, "w+") as index_file: json.dump({}, index_file) self.addCleanup(remove_file, self.TEST_INDEX_FILENAME) self.course_discovery = CourseDiscoveryPage(self.browser) self.dashboard_page = DashboardPage(self.browser) self.course_about = CourseAboutPage(self.browser, self.course_id) # Create a course CourseFixture(self.course_info['org'], self.course_info['number'], self.course_info['run'], self.course_info['display_name'], settings={ 'enrollment_start': datetime(1970, 1, 1).isoformat() }).install() # Create a user and log them in AutoAuthPage(self.browser).visit() def test_register_for_course(self): """ Scenario: I can register for a course Given The course "6.002x" exists And I am logged in And I visit the courses page When I register for the course "6.002x" Then I should see the course numbered "6.002x" in my dashboard And a "edx.course.enrollment.activated" server event is emitted """ # Navigate to the dashboard self.course_discovery.visit() self.course_discovery.click_course(self.course_id) self.course_about.wait_for_page() self.course_about.enroll_in_course() self.dashboard_page.wait_for_page() self.assertTrue(self.dashboard_page.is_course_present(self.course_id)) self.assert_matching_events_were_emitted(event_filter={ 'name': u'edx.course.enrollment.activated', 'event_source': 'server' })
class RegisterCourseTests(EventsTestMixin, UniqueCourseTest): """Test that learner can enroll into a course from courses page""" TEST_INDEX_FILENAME = "test_root/index_file.dat" def setUp(self): """ Initialize the test. Create the necessary page objects, create course page and courses to find. """ super(RegisterCourseTests, self).setUp() # create test file in which index for this test will live with open(self.TEST_INDEX_FILENAME, "w+") as index_file: json.dump({}, index_file) self.addCleanup(remove_file, self.TEST_INDEX_FILENAME) self.course_discovery = CourseDiscoveryPage(self.browser) self.dashboard_page = DashboardPage(self.browser) self.course_about = CourseAboutPage(self.browser, self.course_id) # Create a course CourseFixture( self.course_info['org'], self.course_info['number'], self.course_info['run'], self.course_info['display_name'], settings={'enrollment_start': datetime(1970, 1, 1).isoformat()} ).install() # Create a user and log them in AutoAuthPage(self.browser).visit() def test_register_for_course(self): """ Scenario: I can register for a course Given The course "6.002x" exists And I am logged in And I visit the courses page When I register for the course "6.002x" Then I should see the course numbered "6.002x" in my dashboard And a "edx.course.enrollment.activated" server event is emitted """ # Navigate to the dashboard self.course_discovery.visit() self.course_discovery.click_course(self.course_id) self.course_about.wait_for_page() self.course_about.enroll_in_course() self.dashboard_page.wait_for_page() self.assertTrue(self.dashboard_page.is_course_present(self.course_id)) self.assert_matching_events_were_emitted( event_filter={'name': u'edx.course.enrollment.activated', 'event_source': 'server'} )
def setUp(self): """ Initialize the test. Create the necessary page objects, create course page and courses to find. """ super(RegisterCourseTests, self).setUp() # create test file in which index for this test will live with open(self.TEST_INDEX_FILENAME, "w+") as index_file: json.dump({}, index_file) self.addCleanup(remove_file, self.TEST_INDEX_FILENAME) self.course_discovery = CourseDiscoveryPage(self.browser) self.dashboard_page = DashboardPage(self.browser) self.course_about = CourseAboutPage(self.browser, self.course_id) # Create a course CourseFixture( self.course_info['org'], self.course_info['number'], self.course_info['run'], self.course_info['display_name'], settings={'enrollment_start': datetime(1970, 1, 1).isoformat()} ).install() # Create a user and log them in AutoAuthPage(self.browser).visit()