Merge pull request #4717 from edx/alex/fix_test
Request IFRAME API every time with https scheme.
This commit is contained in:
@@ -74,16 +74,3 @@ class StubYouTubeServiceTest(unittest.TestCase):
|
||||
|
||||
# ensure that server config dict is empty after successful reset
|
||||
self.assertEqual(self.server.config, {})
|
||||
|
||||
|
||||
def test_iframe_response_is_up_to_date(self):
|
||||
"""
|
||||
Check if IFRAME_API_RESPONSE is up-to-date.
|
||||
|
||||
This should prevent issues with IFRAME_API_RESPONSE hard-coding,
|
||||
when hard-coded version is different from actual.
|
||||
"""
|
||||
self.assertEqual(
|
||||
IFRAME_API_RESPONSE,
|
||||
requests.get('https://www.youtube.com/iframe_api').content.strip("\n")
|
||||
)
|
||||
|
||||
@@ -20,20 +20,11 @@ from .http import StubHttpRequestHandler, StubHttpService
|
||||
import json
|
||||
import time
|
||||
import requests
|
||||
import textwrap
|
||||
from urlparse import urlparse
|
||||
from collections import OrderedDict
|
||||
|
||||
|
||||
IFRAME_API_RESPONSE = textwrap.dedent(
|
||||
"if (!window['YT']) {var YT = {loading: 0,loaded: 0};}if (!window['YTConfig']) {var YTConfig"
|
||||
" = {'host': 'http://www.youtube.com'};}if (!YT.loading) {YT.loading = 1;(function(){var l ="
|
||||
" [];YT.ready = function(f) {if (YT.loaded) {f();} else {l.push(f);}};window.onYTReady ="
|
||||
" function() {YT.loaded = 1;for (var i = 0; i < l.length; i++) {try {l[i]();} catch (e) "
|
||||
"{}}};YT.setConfig = function(c) {for (var k in c) {if (c.hasOwnProperty(k)) {YTConfig[k]"
|
||||
" = c[k];}}};var a = document.createElement('script');a.id = 'www-widgetapi-script';a.src"
|
||||
" = 'https:' + '//s.ytimg.com/yts/jsbin/www-widgetapi-vflT-xPmY/www-widgetapi.js';a.async"
|
||||
" = true;var b = document.getElementsByTagName('script')[0];b.parentNode.insertBefore(a, b);})();}")
|
||||
IFRAME_API_RESPONSE = requests.get('https://www.youtube.com/iframe_api').content.strip("\n")
|
||||
|
||||
|
||||
class StubYouTubeHandler(StubHttpRequestHandler):
|
||||
|
||||
Reference in New Issue
Block a user