Merge pull request #3948 from edx/ammar/check-youtube-for-bok-choy
Check YouTube for Bok-Choy
This commit is contained in:
@@ -1,9 +1,41 @@
|
||||
"""
|
||||
Test helper functions and base classes.
|
||||
"""
|
||||
import requests
|
||||
from path import path
|
||||
from bok_choy.web_app_test import WebAppTest
|
||||
from bok_choy.promise import EmptyPromise
|
||||
|
||||
|
||||
def is_youtube_available():
|
||||
"""
|
||||
Check if the required youtube urls are available.
|
||||
|
||||
If a URL in `youtube_api_urls` is not reachable then subsequent URLs will not be checked.
|
||||
|
||||
Returns:
|
||||
bool:
|
||||
|
||||
"""
|
||||
|
||||
youtube_api_urls = {
|
||||
'main': 'https://www.youtube.com/',
|
||||
'player': 'http://www.youtube.com/iframe_api',
|
||||
'metadata': 'http://gdata.youtube.com/feeds/api/videos/',
|
||||
# For transcripts, you need to check an actual video, so we will
|
||||
# just specify our default video and see if that one is available.
|
||||
'transcript': 'http://video.google.com/timedtext?lang=en&v=OEoXaMPEzfM',
|
||||
}
|
||||
|
||||
for url in youtube_api_urls.itervalues():
|
||||
try:
|
||||
response = requests.get(url, allow_redirects=False)
|
||||
except requests.exceptions.ConnectionError:
|
||||
return False
|
||||
|
||||
if response.status_code >= 300:
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
|
||||
def load_data_str(rel_path):
|
||||
|
||||
@@ -5,15 +5,16 @@ Acceptance tests for Video.
|
||||
"""
|
||||
|
||||
import json
|
||||
from unittest import skipIf
|
||||
import requests
|
||||
from ..helpers import UniqueCourseTest
|
||||
from box.test.flaky import flaky
|
||||
from ..helpers import UniqueCourseTest, is_youtube_available
|
||||
from ...pages.lms.video.video import VideoPage
|
||||
from ...pages.lms.tab_nav import TabNavPage
|
||||
from ...pages.lms.course_nav import CourseNavPage
|
||||
from ...pages.lms.auto_auth import AutoAuthPage
|
||||
from ...pages.lms.course_info import CourseInfoPage
|
||||
from ...fixtures.course import CourseFixture, XBlockFixtureDesc
|
||||
from box.test.flaky import flaky
|
||||
|
||||
|
||||
VIDEO_SOURCE_PORT = 8777
|
||||
@@ -39,6 +40,7 @@ class YouTubeConfigError(Exception):
|
||||
|
||||
|
||||
@flaky
|
||||
@skipIf(is_youtube_available() is False, 'YouTube is not available!')
|
||||
class VideoBaseTest(UniqueCourseTest):
|
||||
"""
|
||||
Base class for tests of the Video Player
|
||||
|
||||
Reference in New Issue
Block a user