def test_entrance_exam_has_unit_button(self): """ Test that entrance exam should be created after checking the 'enable entrance exam' checkbox. And user has option to add units only instead of any Subsection. """ self.settings_detail.require_entrance_exam(required=True) self.settings_detail.save_changes() # getting the course outline page. course_outline_page = CourseOutlinePage(self.browser, self.course_info['org'], self.course_info['number'], self.course_info['run']) course_outline_page.visit() course_outline_page.wait_for_ajax() # button with text 'New Unit' should be present. self.assertTrue( element_has_text(page=course_outline_page, css_selector='.add-item a.button-new', text='New Unit')) # button with text 'New Subsection' should not be present. self.assertFalse( element_has_text(page=course_outline_page, css_selector='.add-item a.button-new', text='New Subsection'))
def test_entrance_exam_has_unit_button(self): """ Test that entrance exam should be created after checking the 'enable entrance exam' checkbox. And user has option to add units only instead of any Subsection. """ self.settings_detail.require_entrance_exam(required=True) self.settings_detail.save_changes() # getting the course outline page. course_outline_page = CourseOutlinePage( self.browser, self.course_info['org'], self.course_info['number'], self.course_info['run'] ) course_outline_page.visit() course_outline_page.wait_for_ajax() # button with text 'New Unit' should be present. self.assertTrue(element_has_text( page=course_outline_page, css_selector='.add-item a.button-new', text='New Unit' )) # button with text 'New Subsection' should not be present. self.assertFalse(element_has_text( page=course_outline_page, css_selector='.add-item a.button-new', text='New Subsection' ))
def test_enable_entrance_exam_for_course(self): """ Test that entrance exam should be created after checking the 'enable entrance exam' checkbox. And also that the entrance exam is destroyed after deselecting the checkbox. """ self.settings_detail.require_entrance_exam(required=True) self.settings_detail.save_changes() # getting the course outline page. course_outline_page = CourseOutlinePage( self.browser, self.course_info['org'], self.course_info['number'], self.course_info['run'] ) course_outline_page.visit() # title with text 'Entrance Exam' should be present on page. self.assertTrue(element_has_text( page=course_outline_page, css_selector='span.section-title', text='Entrance Exam' )) # Delete the currently created entrance exam. self.settings_detail.visit() self.settings_detail.require_entrance_exam(required=False) self.settings_detail.save_changes() course_outline_page.visit() self.assertFalse(element_has_text( page=course_outline_page, css_selector='span.section-title', text='Entrance Exam' ))
def test_user_can_correct_course_start_date_warning(self): """ Scenario: User can correct the course start date warning Given I have tried to clear the course start And I have entered a new course start date And I press the "Save" notification button Then The warning about course start date goes away And I reload the page Then my new course start date is shown """ # Set course start date to empty self.settings_page.set_element_values({self.COURSE_START_DATE_CSS: ''}) # Make sure we get error message error_message_css = '.message-error' self.settings_page.wait_for_element_presence(error_message_css, 'Error message is present') self.assertEqual(element_has_text(self.settings_page, error_message_css, "The course must have an assigned start date."), True) # Set new course start value self.settings_page.set_element_values({self.COURSE_START_DATE_CSS: self.course_start_date}) self.settings_page.un_focus_input_field() # Error message disappears self.settings_page.wait_for_element_absence(error_message_css, 'Error message is not present') # Save the changes and refresh the page. self.settings_page.save_changes() self.settings_page.refresh_and_wait_for_load() self.ensure_input_fields_are_loaded() # Assert changes are persistent. self.assertEqual( get_input_value(self.settings_page, self.COURSE_START_DATE_CSS), self.course_start_date )
def test_cannot_clear_the_course_start_date(self): """ Scenario: User cannot clear the course start date Given I have set course dates And I press the "Save" notification button And I clear the course start date Then I receive a warning about course start date And I reload the page And the previously set start date is shown """ # Set dates self.set_course_dates() # Save changes self.settings_page.save_changes() # Get default start date default_start_date = get_input_value(self.settings_page, self.COURSE_START_DATE_CSS) # Set course start date to empty self.settings_page.set_element_values({self.COURSE_START_DATE_CSS: ''}) # Make sure error message is show with appropriate message error_message_css = '.message-error' self.settings_page.wait_for_element_presence(error_message_css, 'Error message is present') self.assertEqual(element_has_text(self.settings_page, error_message_css, "The course must have an assigned start date."), True) # Refresh the page and assert start date has not changed. self.settings_page.refresh_and_wait_for_load() self.ensure_input_fields_are_loaded() self.assertEqual( get_input_value(self.settings_page, self.COURSE_START_DATE_CSS), default_start_date )
def test_entrance_exam_section_2(self): """ Scenario: Any course that is enabled for an entrance exam, should have entrance exam chapter at course page. Given that I am on the course page When I view the course that has an entrance exam Then there should be an "Entrance Exam" chapter.' """ courseware_page = CoursewarePage(self.browser, self.course_id) entrance_exam_link_selector = '.accordion .course-navigation .chapter .group-heading' # visit course page and make sure there is not entrance exam chapter. courseware_page.visit() courseware_page.wait_for_page() self.assertFalse( element_has_text(page=courseware_page, css_selector=entrance_exam_link_selector, text='Entrance Exam')) # Logout and login as a staff. LogoutPage(self.browser).visit() AutoAuthPage(self.browser, course_id=self.course_id, staff=True).visit() # visit course settings page and set/enabled entrance exam for that course. self.settings_page.visit() self.settings_page.require_entrance_exam() self.settings_page.save_changes() # Logout and login as a student. LogoutPage(self.browser).visit() AutoAuthPage(self.browser, course_id=self.course_id, staff=False).visit() # visit course info page and make sure there is an "Entrance Exam" section. courseware_page.visit() courseware_page.wait_for_page() self.assertTrue( element_has_text(page=courseware_page, css_selector=entrance_exam_link_selector, text='Entrance Exam'))
def test_entrance_exam_section_2(self): """ Scenario: Any course that is enabled for an entrance exam, should have entrance exam chapter at course page. Given that I am on the course page When I view the course that has an entrance exam Then there should be an "Entrance Exam" chapter.' """ courseware_page = CoursewarePage(self.browser, self.course_id) entrance_exam_link_selector = '.accordion .course-navigation .chapter .group-heading' # visit course page and make sure there is not entrance exam chapter. courseware_page.visit() courseware_page.wait_for_page() self.assertFalse(element_has_text( page=courseware_page, css_selector=entrance_exam_link_selector, text='Entrance Exam' )) # Logout and login as a staff. LogoutPage(self.browser).visit() AutoAuthPage(self.browser, course_id=self.course_id, staff=True).visit() # visit course settings page and set/enabled entrance exam for that course. self.settings_page.visit() self.settings_page.require_entrance_exam() self.settings_page.save_changes() # Logout and login as a student. LogoutPage(self.browser).visit() AutoAuthPage(self.browser, course_id=self.course_id, staff=False).visit() # visit course info page and make sure there is an "Entrance Exam" section. courseware_page.visit() courseware_page.wait_for_page() self.assertTrue(element_has_text( page=courseware_page, css_selector=entrance_exam_link_selector, text='Entrance Exam' ))