class CourseEngagementVideoTimelineTests(CourseEngagementVideoMixin, WebAppTest): expected_heading = u'What were the viewing patterns for this video?' expected_tooltip = u'The number of learners who watched each segment of the video, and the ' \ u'number of replays for each segment.' expected_table_columns = [u'Time', u'Unique Viewers', u'Replays'] expected_table_heading = u'Total Video Views' def setUp(self): super(CourseEngagementVideoTimelineTests, self).setUp() self.page = CourseEngagementVideoTimelinePage(self.browser) self.course = self.analytics_api_client.courses(self.page.course_id) def test_page(self): super(CourseEngagementVideoTimelineTests, self).test_page() self._test_metrics() if ENABLE_VIDEO_PREVIEW: self._test_video_preview() def _test_video_preview(self): preview_selector = '#module-preview' self.assertFalse(self.page.q(css=preview_selector).visible) toggle_element = self.page.q(css='.collapsible-toggle-text') self.assertTrue(toggle_element.present) self.assertEqual(toggle_element.text[0], 'Expand Preview') toggle_element.click() self.assertEqual(toggle_element.text[0], 'Collapse Preview') self.page.wait_for_element_visibility(preview_selector, 'Video preview is visible') self.fulfill_loading_promise('.module-loading') self.assertElementHasContent(preview_selector) def _test_metrics(self): module_id = UsageKey.from_string(self.page.video_id).html_id() video = [video for video in self.course.videos() if video['encoded_module_id'] == module_id][0] expected_metrics = [ { 'tooltip': 'Estimated percentage of learners who watched the entire video.', 'data_type': 'watched-percent', 'metric_value': self.build_display_percentage( video['users_at_end'], max(video['users_at_start'], video['users_at_end']), zero_percent_default='0%') }, { 'tooltip': 'Learners who started watching the video.', 'data_type': 'started-video', 'metric_value': self.format_number(video['users_at_start']) }, { 'tooltip': 'Learners who watched the video to the end.', 'data_type': 'finished-video', 'metric_value': self.format_number(video['users_at_end']) } ] for expected in expected_metrics: data_selector = 'data-type={0}'.format(expected['data_type']) self.assertSummaryPointValueEquals(data_selector, expected['metric_value']) self.assertSummaryTooltipEquals(data_selector, expected['tooltip'])
class CourseEngagementVideoTimelineTests(CourseEngagementVideoMixin, WebAppTest): expected_heading = u'What were the viewing patterns for this video?' expected_tooltip = u'The number of students who watched each segment of the video, and the ' \ u'number of replays for each segment.' expected_table_columns = [u'Time', u'Unique Viewers', u'Replays'] expected_table_heading = u'Total Video Views' def setUp(self): super(CourseEngagementVideoTimelineTests, self).setUp() self.page = CourseEngagementVideoTimelinePage(self.browser) self.course = self.analytics_api_client.courses(self.page.course_id) def test_page(self): super(CourseEngagementVideoTimelineTests, self).test_page() self._test_metrics() if ENABLE_VIDEO_PREVIEW: self._test_video_preview() def _test_video_preview(self): preview_selector = '#module-preview' self.assertFalse(self.page.q(css=preview_selector).visible) toggle_element = self.page.q(css='.collapsible-toggle-text') self.assertTrue(toggle_element.present) self.assertEqual(toggle_element.text[0], 'Expand Preview') toggle_element.click() self.assertEqual(toggle_element.text[0], 'Collapse Preview') self.page.wait_for_element_visibility(preview_selector, 'Video preview is visible') self.fulfill_loading_promise('.module-loading') self.assertElementHasContent(preview_selector) def _test_metrics(self): module_id = UsageKey.from_string(self.page.video_id).html_id() video = [video for video in self.course.videos() if video['encoded_module_id'] == module_id][0] expected_metrics = [ { 'tooltip': 'Estimated percentage of students who watched the entire video.', 'data_type': 'watched-percent', 'metric_value': self.build_display_percentage( video['users_at_end'], max(video['users_at_start'], video['users_at_end']), zero_percent_default='0%') }, { 'tooltip': 'Students who started watching the video.', 'data_type': 'started-video', 'metric_value': self.format_number(video['users_at_start']) }, { 'tooltip': 'Students who watched the video to the end.', 'data_type': 'finished-video', 'metric_value': self.format_number(video['users_at_end']) } ] for expected in expected_metrics: data_selector = 'data-type={0}'.format(expected['data_type']) self.assertSummaryPointValueEquals(data_selector, expected['metric_value']) self.assertSummaryTooltipEquals(data_selector, expected['tooltip'])
def setUp(self): super(CourseEngagementVideoTimelineTests, self).setUp() self.page = CourseEngagementVideoTimelinePage(self.browser) self.course = self.analytics_api_client.courses(self.page.course_id)