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