def setUp(self): """ Initialization of pages and course fixture for tests """ super(CMSVideoBaseTest, self).setUp() self.video = VideoComponentPage(self.browser) # This will be initialized later self.unit_page = None self.outline = CourseOutlinePage( self.browser, self.course_info['org'], self.course_info['number'], self.course_info['run'] ) self.course_fixture = CourseFixture( self.course_info['org'], self.course_info['number'], self.course_info['run'], self.course_info['display_name'] ) self.assets = [] self.addCleanup(YouTubeStubConfig.reset)
def setUp(self): """ Initialization of pages and course fixture for tests """ super(CMSVideoBaseTest, self).setUp() self.video = VideoComponentPage(self.browser) # This will be initialized later self.unit_page = None self.outline = CourseOutlinePage( self.browser, self.course_info['org'], self.course_info['number'], self.course_info['run'] ) self.course_fixture = CourseFixture( self.course_info['org'], self.course_info['number'], self.course_info['run'], self.course_info['display_name'] ) self.assets = [] self.metadata = None self.addCleanup(YouTubeStubConfig.reset)
class CMSVideoBaseTest(UniqueCourseTest): """ CMS Video Module Base Test Class """ def setUp(self): """ Initialization of pages and course fixture for tests """ super(CMSVideoBaseTest, self).setUp() self.video = VideoComponentPage(self.browser) # This will be initialized later self.unit_page = None self.outline = CourseOutlinePage( self.browser, self.course_info['org'], self.course_info['number'], self.course_info['run'] ) self.course_fixture = CourseFixture( self.course_info['org'], self.course_info['number'], self.course_info['run'], self.course_info['display_name'] ) self.assets = [] self.metadata = None self.addCleanup(YouTubeStubConfig.reset) def _create_course_unit(self, youtube_stub_config=None, subtitles=False): """ Create a Studio Video Course Unit and Navigate to it. Arguments: youtube_stub_config (dict) subtitles (bool) """ if youtube_stub_config: YouTubeStubConfig.configure(youtube_stub_config) if subtitles: self.assets.append('subs_3_yD_cEKoCk.srt.sjson') self.navigate_to_course_unit() def _create_video(self): """ Create Xblock Video Component. """ self.video.create_video() video_xblocks = self.video.xblocks() # Total video xblock components count should be equals to 2 # Why 2? One video component is created by default for each test. Please see # test_studio_video_module.py:CMSVideoTest._create_course_unit # And we are creating second video component here. self.assertEqual(video_xblocks, 2) def _install_course_fixture(self): """ Prepare for tests by creating a course with a section, subsection, and unit. Performs the following: Create a course with a section, subsection, and unit Create a user and make that user a course author Log the user into studio """ if self.assets: self.course_fixture.add_asset(self.assets) # Create course with Video component self.course_fixture.add_children( XBlockFixtureDesc('chapter', 'Test Section').add_children( XBlockFixtureDesc('sequential', 'Test Subsection').add_children( XBlockFixtureDesc('vertical', 'Test Unit').add_children( XBlockFixtureDesc('video', 'Video', metadata=self.metadata) ) ) ) ).install() # Auto login and register the course AutoAuthPage( self.browser, staff=False, username=self.course_fixture.user.get('username'), email=self.course_fixture.user.get('email'), password=self.course_fixture.user.get('password') ).visit() def _navigate_to_course_unit_page(self): """ Open the course from the dashboard and expand the section and subsection and click on the Unit link The end result is the page where the user is editing the newly created unit """ # Visit Course Outline page self.outline.visit() # Visit Unit page self.unit_page = self.outline.section('Test Section').subsection('Test Subsection').expand_subsection().unit( 'Test Unit').go_to() self.video.wait_for_video_component_render() def navigate_to_course_unit(self): """ Install the course with required components and navigate to course unit page """ self._install_course_fixture() self._navigate_to_course_unit_page() def edit_component(self, xblock_index=1): """ Open component Edit Dialog for first component on page. Arguments: xblock_index: number starting from 1 (0th entry is the unit page itself) """ self.unit_page.xblocks[xblock_index].edit() EmptyPromise( lambda: self.video.q(css='div.basic_metadata_edit').visible, "Wait for the basic editor to be open", timeout=5 ).fulfill() def open_advanced_tab(self): """ Open components advanced tab. """ # The 0th entry is the unit page itself. self.unit_page.xblocks[1].open_advanced_tab() def open_basic_tab(self): """ Open components basic tab. """ # The 0th entry is the unit page itself. self.unit_page.xblocks[1].open_basic_tab() def save_unit_settings(self): """ Save component settings. """ # The 0th entry is the unit page itself. self.unit_page.xblocks[1].save_settings()
class CMSVideoBaseTest(UniqueCourseTest): """ CMS Video Module Base Test Class """ def setUp(self): """ Initialization of pages and course fixture for tests """ super(CMSVideoBaseTest, self).setUp() self.video = VideoComponentPage(self.browser) # This will be initialized later self.unit_page = None self.outline = CourseOutlinePage(self.browser, self.course_info['org'], self.course_info['number'], self.course_info['run']) self.course_fixture = CourseFixture(self.course_info['org'], self.course_info['number'], self.course_info['run'], self.course_info['display_name']) self.assets = [] self.metadata = None self.addCleanup(YouTubeStubConfig.reset) def _create_course_unit(self, youtube_stub_config=None, subtitles=False): """ Create a Studio Video Course Unit and Navigate to it. Arguments: youtube_stub_config (dict) subtitles (bool) """ if youtube_stub_config: YouTubeStubConfig.configure(youtube_stub_config) if subtitles: self.assets.append('subs_3_yD_cEKoCk.srt.sjson') self.navigate_to_course_unit() def _create_video(self): """ Create Xblock Video Component. """ self.video.create_video() video_xblocks = self.video.xblocks() # Total video xblock components count should be equals to 2 # Why 2? One video component is created by default for each test. Please see # test_studio_video_module.py:CMSVideoTest._create_course_unit # And we are creating second video component here. self.assertEqual(video_xblocks, 2) def _install_course_fixture(self): """ Prepare for tests by creating a course with a section, subsection, and unit. Performs the following: Create a course with a section, subsection, and unit Create a user and make that user a course author Log the user into studio """ if self.assets: self.course_fixture.add_asset(self.assets) # Create course with Video component self.course_fixture.add_children( XBlockFixtureDesc('chapter', 'Test Section').add_children( XBlockFixtureDesc( 'sequential', 'Test Subsection').add_children( XBlockFixtureDesc( 'vertical', 'Test Unit').add_children( XBlockFixtureDesc( 'video', 'Video', metadata=self.metadata))))).install() # Auto login and register the course AutoAuthPage( self.browser, staff=False, username=self.course_fixture.user.get('username'), email=self.course_fixture.user.get('email'), password=self.course_fixture.user.get('password')).visit() def _navigate_to_course_unit_page(self): """ Open the course from the dashboard and expand the section and subsection and click on the Unit link The end result is the page where the user is editing the newly created unit """ # Visit Course Outline page self.outline.visit() # Visit Unit page self.unit_page = self.outline.section('Test Section').subsection( 'Test Subsection').expand_subsection().unit('Test Unit').go_to() self.video.wait_for_video_component_render() def navigate_to_course_unit(self): """ Install the course with required components and navigate to course unit page """ self._install_course_fixture() self._navigate_to_course_unit_page() def edit_component(self, xblock_index=1): """ Open component Edit Dialog for first component on page. Arguments: xblock_index: number starting from 1 (0th entry is the unit page itself) """ self.unit_page.xblocks[xblock_index].edit() EmptyPromise( lambda: self.video.q(css='div.basic_metadata_edit').visible, "Wait for the basic editor to be open", timeout=5).fulfill() def open_advanced_tab(self): """ Open components advanced tab. """ # The 0th entry is the unit page itself. self.unit_page.xblocks[1].open_advanced_tab() def open_basic_tab(self): """ Open components basic tab. """ # The 0th entry is the unit page itself. self.unit_page.xblocks[1].open_basic_tab() def save_unit_settings(self): """ Save component settings. """ # The 0th entry is the unit page itself. self.unit_page.xblocks[1].save_settings()