Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-analytics-data-api
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-analytics-data-api
Commits
bbb67343
Commit
bbb67343
authored
Jan 17, 2017
by
Tyler Hallada
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fallback to fake video ids when LMS down
parent
b23464c7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
0 deletions
+15
-0
analyticsdataserver/clients.py
+5
-0
analyticsdataserver/tests.py
+10
-0
No files found.
analyticsdataserver/clients.py
View file @
bbb67343
import
logging
from
requests.exceptions
import
RequestException
from
edx_rest_api_client.client
import
EdxRestApiClient
from
edx_rest_api_client.exceptions
import
HttpClientError
from
opaque_keys.edx.keys
import
UsageKey
...
...
@@ -40,6 +42,9 @@ class CourseBlocksApiClient(EdxRestApiClient):
else
:
logger
.
warning
(
"Course Blocks API failed to return video ids (
%
s)."
,
e
.
response
.
status_code
)
return
None
except
RequestException
as
e
:
logger
.
warning
(
"Course Blocks API request failed. Is the LMS running?: "
+
str
(
e
))
return
None
# Setup a terrible hack to silence mysterious flood of ImportErrors from stevedore inside edx-opaque-keys.
# (The UsageKey utility still works despite the import errors, so I think the errors are not important).
...
...
analyticsdataserver/tests.py
View file @
bbb67343
...
...
@@ -11,6 +11,7 @@ from django.db.utils import ConnectionHandler, DatabaseError
from
django.test
import
TestCase
from
django.test.utils
import
override_settings
from
rest_framework.authtoken.models
import
Token
from
requests.exceptions
import
ConnectionError
from
analytics_data_api.v0.models
import
CourseEnrollmentDaily
,
CourseEnrollmentByBirthYear
from
analyticsdataserver.clients
import
CourseBlocksApiClient
...
...
@@ -177,6 +178,15 @@ class ClientTests(TestCase):
self
.
assertEqual
(
videos
,
None
)
@responses.activate
@mock.patch
(
'analyticsdataserver.clients.logger'
)
def
test_all_videos_connection_error
(
self
,
logger
):
exception
=
ConnectionError
(
'LMS is dead'
)
responses
.
add
(
responses
.
GET
,
'http://example.com/blocks/'
,
body
=
exception
)
videos
=
self
.
client
.
all_videos
(
'course_id'
)
logger
.
warning
.
assert_called_with
(
'Course Blocks API request failed. Is the LMS running?: '
+
str
(
exception
))
self
.
assertEqual
(
videos
,
None
)
@responses.activate
def
test_all_videos_pass_through_bad_id
(
self
):
responses
.
add
(
responses
.
GET
,
'http://example.com/blocks/'
,
body
=
json
.
dumps
({
'blocks'
:
{
'block-v1:edX+DemoX+Demo_Course+type@video+block@5c90cffecd9b48b188cbfea176bf7fe9'
:
{
...
...
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