From 4b551b53576d34cf56e7629bbe8b08e943c8374c Mon Sep 17 00:00:00 2001 From: polesye Date: Tue, 10 Feb 2015 13:00:01 +0200 Subject: [PATCH] TNL-454: Fix flaky bok-choy tests. --- .../test/acceptance/pages/lms/video/video.py | 10 ++---- .../tests/video/test_studio_video_module.py | 1 + .../tests/video/test_video_times.py | 36 +++++++++---------- 3 files changed, 20 insertions(+), 27 deletions(-) diff --git a/common/test/acceptance/pages/lms/video/video.py b/common/test/acceptance/pages/lms/video/video.py index 0b13dd5f97..37d7251591 100644 --- a/common/test/acceptance/pages/lms/video/video.py +++ b/common/test/acceptance/pages/lms/video/video.py @@ -356,10 +356,6 @@ class VideoPage(PageObject): self.q(css=button_selector).first.click() - button_states = {'play': 'playing', 'pause': 'pause'} - if button in button_states: - self.wait_for_state(button_states[button]) - self.wait_for_ajax() def _get_element_dimensions(self, selector): @@ -677,7 +673,7 @@ class VideoPage(PageObject): elif 'is-ended' in current_state: return 'finished' - def _wait_for(self, check_func, desc, result=False, timeout=200): + def _wait_for(self, check_func, desc, result=False, timeout=200, try_interval=0.2): """ Calls the method provided as an argument until the Promise satisfied or BrokenPromise @@ -689,9 +685,9 @@ class VideoPage(PageObject): """ if result: - return Promise(check_func, desc, timeout=timeout).fulfill() + return Promise(check_func, desc, timeout=timeout, try_interval=try_interval).fulfill() else: - return EmptyPromise(check_func, desc, timeout=timeout).fulfill() + return EmptyPromise(check_func, desc, timeout=timeout, try_interval=try_interval).fulfill() def wait_for_state(self, state): """ diff --git a/common/test/acceptance/tests/video/test_studio_video_module.py b/common/test/acceptance/tests/video/test_studio_video_module.py index 0cb985e8b5..b069c6fa70 100644 --- a/common/test/acceptance/tests/video/test_studio_video_module.py +++ b/common/test/acceptance/tests/video/test_studio_video_module.py @@ -181,6 +181,7 @@ class CMSVideoTest(CMSVideoBaseTest): self.assertTrue(self.video.is_button_shown('play')) self.video.click_player_button('play') + self.video.wait_for_state('playing') self.assertTrue(self.video.is_button_shown('pause')) def test_youtube_stub_blocks_youtube_api(self): diff --git a/common/test/acceptance/tests/video/test_video_times.py b/common/test/acceptance/tests/video/test_video_times.py index fb88004652..810b042bd4 100644 --- a/common/test/acceptance/tests/video/test_video_times.py +++ b/common/test/acceptance/tests/video/test_video_times.py @@ -3,7 +3,6 @@ Acceptance tests for Video Times(Start, End and Finish) functionality. """ from .test_video_module import VideoBaseTest -from unittest import skip class VideoTimesTest(VideoBaseTest): @@ -33,17 +32,16 @@ class VideoTimesTest(VideoBaseTest): self.assertGreaterEqual(int(self.video.position.split(':')[1]), 10) - @skip("Intermittently fails 1 Oct 2014") def test_video_end_time_with_default_start_time(self): """ Scenario: End time works for Youtube video if starts playing from beginning. - Given we have a video in "Youtube" mode with end time set to 00:00:02 + Given we have a video in "Youtube" mode with end time set to 00:00:05 And I click video button "play" And I wait until video stop playing - Then I see video slider at "0:02" position + Then I see video slider at "0:05" position """ - data = {'end_time': '00:00:02'} + data = {'end_time': '00:00:05'} self.metadata = self.metadata_for_mode('youtube', additional_data=data) # go to video @@ -54,7 +52,7 @@ class VideoTimesTest(VideoBaseTest): # wait until video stop playing self.video.wait_for_state('pause') - self.assertEqual(self.video.position, '0:02') + self.assertIn(self.video.position, ('0:05', '0:06')) def test_video_end_time_wo_default_start_time(self): """ @@ -79,20 +77,19 @@ class VideoTimesTest(VideoBaseTest): # wait until video stop playing self.video.wait_for_state('pause') - self.assertEqual(self.video.position, '1:00') + self.assertIn(self.video.position, ('1:00', '1:01')) - @skip("Intermittently fails 23 Sept 2014") def test_video_start_time_and_end_time(self): """ Scenario: Start time and end time work together for Youtube video. - Given we a video in "Youtube" mode with start time set to 00:00:10 and end_time set to 00:00:12 + Given we a video in "Youtube" mode with start time set to 00:00:10 and end_time set to 00:00:15 And I see video slider at "0:10" position And I click video button "play" Then I wait until video stop playing - Then I see video slider at "0:12" position + Then I see video slider at "0:15" position """ - data = {'start_time': '00:00:10', 'end_time': '00:00:12'} + data = {'start_time': '00:00:10', 'end_time': '00:00:15'} self.metadata = self.metadata_for_mode('youtube', additional_data=data) # go to video @@ -105,13 +102,12 @@ class VideoTimesTest(VideoBaseTest): # wait until video stop playing self.video.wait_for_state('pause') - self.assertEqual(self.video.position, '0:12') + self.assertIn(self.video.position, ('0:15', '0:16')) - @skip("Intermittently fails 03 June 2014") def test_video_end_time_and_finish_time(self): """ Scenario: Youtube video works after pausing at end time and then plays again from End Time to the end. - Given we have a video in "Youtube" mode with start time set to 00:02:14 and end_time set to 00:02:15 + Given we have a video in "Youtube" mode with start time set to 00:02:10 and end_time set to 00:02:15 And I click video button "play" And I wait until video stop playing Then I see video slider at "2:15" position @@ -119,7 +115,7 @@ class VideoTimesTest(VideoBaseTest): And I wait until video stop playing Then I see video slider at "2:20" position """ - data = {'start_time': '00:02:14', 'end_time': '00:02:15'} + data = {'start_time': '00:02:10', 'end_time': '00:02:15'} self.metadata = self.metadata_for_mode('youtube', additional_data=data) # go to video @@ -130,7 +126,7 @@ class VideoTimesTest(VideoBaseTest): # wait until video stop playing self.video.wait_for_state('pause') - self.assertEqual(self.video.position, '2:15') + self.assertIn(self.video.position, ('2:15', '2:16')) self.video.click_player_button('play') @@ -142,14 +138,14 @@ class VideoTimesTest(VideoBaseTest): def test_video_end_time_with_seek(self): """ Scenario: End Time works for Youtube Video if starts playing before Start Time. - Given we have a video in "Youtube" mode with end-time at 0:32 and start-time at 0:30 + Given we have a video in "Youtube" mode with end-time at 0:35 and start-time at 0:30 And I seek video to "0:28" position And I click video button "play" And I wait until video stop playing - Then I see video slider at "0:32" position + Then I see video slider at "0:35" position """ - data = {'start_time': '00:00:30', 'end_time': '00:00:32'} + data = {'start_time': '00:00:30', 'end_time': '00:00:35'} self.metadata = self.metadata_for_mode('youtube', additional_data=data) # go to video @@ -162,7 +158,7 @@ class VideoTimesTest(VideoBaseTest): # wait until video stop playing self.video.wait_for_state('pause') - self.assertEqual(self.video.position, '0:32') + self.assertIn(self.video.position, ('0:35', '0:36')) def test_video_finish_time_with_seek(self): """