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
ba673f8f
Commit
ba673f8f
authored
Jun 02, 2014
by
muhammad-ammar
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3949 from edx/ammar/improve-lettuce-youtube-availability-check
Lettuce YouTube Check Improvements
parents
ba0bad1d
84ac5628
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
10 deletions
+16
-10
common/djangoapps/terrain/setup_prereqs.py
+16
-10
No files found.
common/djangoapps/terrain/setup_prereqs.py
View file @
ba673f8f
...
...
@@ -15,6 +15,9 @@ from terrain.stubs.video_source import VideoSourceHttpService
import
re
import
requests
from
logging
import
getLogger
LOGGER
=
getLogger
(
__name__
)
SERVICES
=
{
"youtube"
:
{
"port"
:
settings
.
YOUTUBE_PORT
,
"class"
:
StubYouTubeService
},
...
...
@@ -77,7 +80,9 @@ def process_requires_tags(scenario):
if
requires
:
if
requires
.
group
(
'server'
)
==
'youtube'
:
if
not
is_youtube_available
(
scenario
,
YOUTUBE_API_URLS
):
if
not
is_youtube_available
(
YOUTUBE_API_URLS
):
# A hackish way to skip a test in lettuce as there is no proper way to skip a test conditionally
scenario
.
steps
=
[]
return
start_stub
(
requires
.
group
(
'server'
))
...
...
@@ -96,21 +101,22 @@ def start_stub(name):
setattr
(
world
,
name
,
fake_server
)
def
is_youtube_available
(
scenario
,
urls
):
def
is_youtube_available
(
urls
):
"""
Check if the required youtube urls are available.
If they are not, then skip the scenario.
"""
for
name
,
url
in
urls
.
iteritems
():
response
=
requests
.
get
(
url
,
allow_redirects
=
False
)
status
=
response
.
status_code
if
status
!=
200
:
print
"ERROR: YouTube {0} service not available. Status code: {1}"
.
format
(
name
,
status
)
try
:
response
=
requests
.
get
(
url
,
allow_redirects
=
False
)
except
requests
.
exceptions
.
ConnectionError
:
LOGGER
.
warning
(
"Connection Error. YouTube {0} service not available. Skipping this test."
.
format
(
name
))
return
False
# This is a hackish way to skip a test in lettuce as there is
# no proper way to skip a test conditionally
scenario
.
steps
=
[]
status
=
response
.
status_code
if
status
>=
300
:
LOGGER
.
warning
(
"YouTube {0} service not available. Status code: {1}. Skipping this test."
.
format
(
name
,
status
))
# No need to check all the URLs
return
False
...
...
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