Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
3bdee98f
Commit
3bdee98f
authored
Jan 15, 2015
by
Jesse Zoldak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Request the iframe API from youtube in tests every time it is needed
TNL-454
parent
9e20057d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
10 deletions
+6
-10
common/djangoapps/terrain/stubs/youtube.py
+6
-10
No files found.
common/djangoapps/terrain/stubs/youtube.py
View file @
3bdee98f
...
...
@@ -24,9 +24,6 @@ from urlparse import urlparse
from
collections
import
OrderedDict
IFRAME_API_RESPONSE
=
None
class
StubYouTubeHandler
(
StubHttpRequestHandler
):
"""
A handler for Youtube GET requests.
...
...
@@ -50,12 +47,6 @@ class StubYouTubeHandler(StubHttpRequestHandler):
"""
Handle a GET request from the client and sends response back.
"""
# Initialize only once if IFRAME_API_RESPONSE is none.
global
IFRAME_API_RESPONSE
# pylint: disable=global-statement
if
IFRAME_API_RESPONSE
is
None
:
IFRAME_API_RESPONSE
=
requests
.
get
(
'https://www.youtube.com/iframe_api'
)
.
content
.
strip
(
"
\n
"
)
self
.
log_message
(
"Youtube provider received GET request to path {}"
.
format
(
self
.
path
)
)
...
...
@@ -104,7 +95,12 @@ class StubYouTubeHandler(StubHttpRequestHandler):
if
self
.
server
.
config
.
get
(
'youtube_api_blocked'
):
self
.
send_response
(
404
,
content
=
''
,
headers
=
{
'Content-type'
:
'text/plain'
})
else
:
self
.
send_response
(
200
,
content
=
IFRAME_API_RESPONSE
,
headers
=
{
'Content-type'
:
'text/html'
})
# Get the response to send from YouTube.
# We need to do this every time because Google sometimes sends different responses
# as part of their own experiments, which has caused our tests to become "flaky"
self
.
log_message
(
"Getting iframe api from youtube.com"
)
iframe_api_response
=
requests
.
get
(
'https://www.youtube.com/iframe_api'
)
.
content
.
strip
(
"
\n
"
)
self
.
send_response
(
200
,
content
=
iframe_api_response
,
headers
=
{
'Content-type'
:
'text/html'
})
else
:
self
.
send_response
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment