def setUp(self): """ Initialization of pages and course fixture for video tests """ super(VideoBaseTest, self).setUp() self.video = VideoPage(self.browser) self.tab_nav = TabNavPage(self.browser) self.course_nav = CourseNavPage(self.browser) self.courseware = CoursewarePage(self.browser, self.course_id) self.course_info_page = CourseInfoPage(self.browser, self.course_id) self.auth_page = AutoAuthPage(self.browser, course_id=self.course_id) self.course_fixture = CourseFixture( self.course_info['org'], self.course_info['number'], self.course_info['run'], self.course_info['display_name'] ) self.metadata = None self.assets = [] self.contents_of_verticals = None self.youtube_configuration = {} self.user_info = {} # reset youtube stub server self.addCleanup(YouTubeStubConfig.reset)
def log_in_as_unique_user(self): """ Create a unique user and return the account's username and id. """ username = "******".format(uuid=self.unique_id[0:6]) auto_auth_page = AutoAuthPage(self.browser, username=username).visit() user_id = auto_auth_page.get_user_id() return username, user_id
def log_in_as_unique_user(self, email=None, full_name=None): """ Create a unique user and return the account's username and id. """ username = "******".format(uuid=self.unique_id[0:6]) auto_auth_page = AutoAuthPage(self.browser, username=username, email=email, full_name=full_name).visit() user_id = auto_auth_page.get_user_id() return username, user_id
def auth(self, enroll=True): """Authenticate, enrolling the user in the configured course if requested.""" CourseFixture(**self.course_info).install() course_id = self.course_id if enroll else None auth_page = AutoAuthPage(self.browser, course_id=course_id) auth_page.visit() self.username = auth_page.user_info['username']
def setUp(self): """ Initializes the components (page objects, courses, users) for this test suite """ # Some parameters are provided by the parent setUp() routine, such as the following: # self.course_id, self.course_info, self.unique_id super(BaseLmsDashboardTest, self).setUp() # Load page objects for use by the tests self.dashboard_page = DashboardPage(self.browser) # Configure some aspects of the test course and install the settings into the course self.course_fixture = CourseFixture( self.course_info["org"], self.course_info["number"], self.course_info["run"], self.course_info["display_name"], ) self.course_fixture.add_advanced_settings( {u"social_sharing_url": { u"value": "http://custom/course/url" }}) self.course_fixture.install() self.username = "******".format(uuid=self.unique_id[0:6]) self.email = "{user}@example.com".format(user=self.username) # Create the test user, register them for the course, and authenticate AutoAuthPage(self.browser, username=self.username, email=self.email, course_id=self.course_id).visit() # Navigate the authenticated, enrolled user to the dashboard page and get testing! self.dashboard_page.visit()
def test_badge_share_modal(self): username = '******' AutoAuthPage(self.browser, username=username).visit() profile_page = self.visit_profile_page(username) profile_page.display_accomplishments() badge = profile_page.badges[0] badge.display_modal() badge.close_modal()
def auto_auth(self, username, email): """ Logout and login with given credentials. """ AutoAuthPage(self.browser, username=username, email=email, course_id=self.course_id, staff=True).visit()
def log_in_as_unique_user(self): """ Log in as a valid lms user. """ AutoAuthPage(self.browser, username="******", email="*****@*****.**", password="******", course_id=self.course_id).visit()
def setUp(self): """ Setup course """ super(LmsPerformanceTest, self).setUp() # Install a course with sections/problems, tabs, updates, and handouts course_fix = CourseFixture(self.course_info['org'], self.course_info['number'], self.course_info['run'], self.course_info['display_name']) course_fix.add_update( CourseUpdateDesc(date='January 29, 2014', content='Test course update1')) course_fix.add_update( CourseUpdateDesc(date='January 30, 2014', content='Test course update2')) course_fix.add_update( CourseUpdateDesc(date='January 31, 2014', content='Test course update3')) course_fix.add_children( XBlockFixtureDesc('chapter', 'Test Section 1').add_children( XBlockFixtureDesc( 'sequential', 'Test Subsection 1').add_children( XBlockFixtureDesc( 'problem', 'Test Problem 1', data=load_data_str('multiple_choice.xml')), XBlockFixtureDesc( 'problem', 'Test Problem 2', data=load_data_str('formula_problem.xml')), XBlockFixtureDesc('html', 'Test HTML', data="<html>Html child text</html>"), )), XBlockFixtureDesc('chapter', 'Test Section 2').add_children( XBlockFixtureDesc( 'sequential', 'Test Subsection 2').add_children( XBlockFixtureDesc( 'html', 'Html Child', data="<html>Html child text</html>"))), XBlockFixtureDesc('chapter', 'Test Section 3').add_children( XBlockFixtureDesc('sequential', 'Test Subsection 3').add_children( XBlockFixtureDesc( 'problem', 'Test Problem 3')))).install() AutoAuthPage(self.browser, username=self.username, email=self.email, course_id=self.course_id).visit()
def test_badges_accessibility(self): """ Test the accessibility of the badge listings and sharing modal. """ username = '******' AutoAuthPage(self.browser, username=username).visit() profile_page = self.visit_profile_page(username) profile_page.display_accomplishments() profile_page.a11y_audit.check_for_accessibility_errors() profile_page.badges[0].display_modal() profile_page.a11y_audit.check_for_accessibility_errors()
def setUp(self): """ Create a unique identifier for the course used in this test. """ # Ensure that the superclass sets up super(XBlockAcidBase, self).setUp() self.setup_fixtures() AutoAuthPage(self.browser, course_id=self.course_id).visit() self.courseware_page = CoursewarePage(self.browser, self.course_id)
def test_cohort_visibility_label(self): # Must be moderator to view content in a cohort other than your own AutoAuthPage(self.browser, course_id=self.course_id, roles="Moderator").visit() self.thread_id = self.setup_thread(1, group_id=self.cohort_1_id) self.assertEquals( self.thread_page.get_group_visibility_label(), "This post is visible only to {}.".format(self.cohort_1_name) ) # Disable cohorts and verify that the post now shows as visible to everyone. self.disable_cohorting(self.course_fixture) self.refresh_thread_page(self.thread_id) self.assertEquals(self.thread_page.get_group_visibility_label(), "This post is visible to everyone.")
def test_badges_accessibility(self): """ Test the accessibility of the badge listings and sharing modal. """ username = '******' AutoAuthPage(self.browser, username=username).visit() profile_page = self.visit_profile_page(username) profile_page.a11y_audit.config.set_rules({ "ignore": [ 'link-href', # TODO: AC-231 'color-contrast', # TODO: AC-231 ], }) profile_page.display_accomplishments() profile_page.a11y_audit.check_for_accessibility_errors() profile_page.badges[0].display_modal() profile_page.a11y_audit.check_for_accessibility_errors()
def setUp(self): super(InlineDiscussionTest, self).setUp() self.discussion_id = "test_discussion_{}".format(uuid4().hex) self.course_fixture = CourseFixture(**self.course_info).add_children( XBlockFixtureDesc("chapter", "Test Section").add_children( XBlockFixtureDesc( "sequential", "Test Subsection").add_children( XBlockFixtureDesc( "vertical", "Test Unit").add_children( XBlockFixtureDesc("discussion", "Test Discussion", metadata={ "discussion_id": self.discussion_id }))))).install() self.setup_cohorts() self.user_id = AutoAuthPage( self.browser, course_id=self.course_id).visit().get_user_id()
def setUp(self): """ Initializes the components (page objects, courses, users) for this test suite """ # Some parameters are provided by the parent setUp() routine, such as the following: # self.course_id, self.course_info, self.unique_id super(BaseLmsDashboardTestMultiple, self).setUp() # Load page objects for use by the tests self.dashboard_page = DashboardPage(self.browser) # Configure some aspects of the test course and install the settings into the course self.courses = { 'A': { 'org': 'test_org', 'number': self.unique_id, 'run': 'test_run_A', 'display_name': 'Test Course A' }, 'B': { 'org': 'test_org', 'number': self.unique_id, 'run': 'test_run_B', 'display_name': 'Test Course B' }, 'C': { 'org': 'test_org', 'number': self.unique_id, 'run': 'test_run_C', 'display_name': 'Test Course C' } } self.username = "******".format(uuid=self.unique_id[0:6]) self.email = "{user}@example.com".format(user=self.username) self.course_keys = {} self.course_fixtures = {} for key, value in self.courses.iteritems(): course_key = generate_course_key( value['org'], value['number'], value['run'], ) course_fixture = CourseFixture( value['org'], value['number'], value['run'], value['display_name'], ) course_fixture.add_advanced_settings({ u"social_sharing_url": { u"value": "http://custom/course/url" } }) course_fixture.install() self.course_keys[key] = course_key self.course_fixtures[key] = course_fixture # Create the test user, register them for the course, and authenticate AutoAuthPage(self.browser, username=self.username, email=self.email, course_id=course_key).visit() # Navigate the authenticated, enrolled user to the dashboard page and get testing! self.dashboard_page.visit()
def setUp(self): super(DiscussionTabSingleThreadTest, self).setUp() self.setup_cohorts() AutoAuthPage(self.browser, course_id=self.course_id).visit()
def _auth(self): """Authenticate the user.""" AutoAuthPage(self.browser).visit()
class VideoBaseTest(UniqueCourseTest): """ Base class for tests of the Video Player Sets up the course and provides helper functions for the Video tests. """ def setUp(self): """ Initialization of pages and course fixture for video tests """ super(VideoBaseTest, self).setUp() self.video = VideoPage(self.browser) self.tab_nav = TabNavPage(self.browser) self.course_nav = CourseNavPage(self.browser) self.courseware = CoursewarePage(self.browser, self.course_id) self.course_info_page = CourseInfoPage(self.browser, self.course_id) self.auth_page = AutoAuthPage(self.browser, course_id=self.course_id) self.course_fixture = CourseFixture( self.course_info['org'], self.course_info['number'], self.course_info['run'], self.course_info['display_name'] ) self.metadata = None self.assets = [] self.contents_of_verticals = None self.youtube_configuration = {} self.user_info = {} # reset youtube stub server self.addCleanup(YouTubeStubConfig.reset) def navigate_to_video(self): """ Prepare the course and get to the video and render it """ self._install_course_fixture() self._navigate_to_courseware_video_and_render() def navigate_to_video_no_render(self): """ Prepare the course and get to the video unit however do not wait for it to render, because the has been an error. """ self._install_course_fixture() self._navigate_to_courseware_video_no_render() def _install_course_fixture(self): """ Install the course fixture that has been defined """ if self.assets: self.course_fixture.add_asset(self.assets) chapter_sequential = XBlockFixtureDesc('sequential', 'Test Section') chapter_sequential.add_children(*self._add_course_verticals()) chapter = XBlockFixtureDesc('chapter', 'Test Chapter').add_children(chapter_sequential) self.course_fixture.add_children(chapter) self.course_fixture.install() if len(self.youtube_configuration) > 0: YouTubeStubConfig.configure(self.youtube_configuration) def _add_course_verticals(self): """ Create XBlockFixtureDesc verticals :return: a list of XBlockFixtureDesc """ xblock_verticals = [] _contents_of_verticals = self.contents_of_verticals # Video tests require at least one vertical with a single video. if not _contents_of_verticals: _contents_of_verticals = [[{'display_name': 'Video', 'metadata': self.metadata}]] for vertical_index, vertical in enumerate(_contents_of_verticals): xblock_verticals.append(self._create_single_vertical(vertical, vertical_index)) return xblock_verticals def _create_single_vertical(self, vertical_contents, vertical_index): """ Create a single course vertical of type XBlockFixtureDesc with category `vertical`. A single course vertical can contain single or multiple video modules. :param vertical_contents: a list of items for the vertical to contain :param vertical_index: index for the vertical display name :return: XBlockFixtureDesc """ xblock_course_vertical = XBlockFixtureDesc('vertical', 'Test Vertical-{0}'.format(vertical_index)) for video in vertical_contents: xblock_course_vertical.add_children( XBlockFixtureDesc('video', video['display_name'], metadata=video.get('metadata'))) return xblock_course_vertical def _navigate_to_courseware_video(self): """ Register for the course and navigate to the video unit """ self.auth_page.visit() self.user_info = self.auth_page.user_info self.course_info_page.visit() self.tab_nav.go_to_tab('Course') def _navigate_to_courseware_video_and_render(self): """ Wait for the video player to render """ self._navigate_to_courseware_video() self.video.wait_for_video_player_render() def _navigate_to_courseware_video_no_render(self): """ Wait for the video Xmodule but not for rendering """ self._navigate_to_courseware_video() self.video.wait_for_video_class() def metadata_for_mode(self, player_mode, additional_data=None): """ Create a dictionary for video player configuration according to `player_mode` :param player_mode (str): Video player mode :param additional_data (dict): Optional additional metadata. :return: dict """ metadata = {} if player_mode == 'html5': metadata.update({ 'youtube_id_1_0': '', 'youtube_id_0_75': '', 'youtube_id_1_25': '', 'youtube_id_1_5': '', 'html5_sources': HTML5_SOURCES }) if player_mode == 'youtube_html5': metadata.update({ 'html5_sources': HTML5_SOURCES, }) if player_mode == 'youtube_html5_unsupported_video': metadata.update({ 'html5_sources': HTML5_SOURCES_INCORRECT }) if player_mode == 'html5_unsupported_video': metadata.update({ 'youtube_id_1_0': '', 'youtube_id_0_75': '', 'youtube_id_1_25': '', 'youtube_id_1_5': '', 'html5_sources': HTML5_SOURCES_INCORRECT }) if additional_data: metadata.update(additional_data) return metadata def go_to_sequential_position(self, position): """ Navigate to sequential specified by `video_display_name` """ self.courseware.go_to_sequential_position(position) self.video.wait_for_video_player_render()