Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-analytics-data-api-client
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
OpenEdx
edx-analytics-data-api-client
Commits
fb9e563d
Commit
fb9e563d
authored
Jul 11, 2014
by
Clinton Blackburn
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6 from edx/trailing-slash
Added trailing slashes to URLs to avoid redirect
parents
6bd371c7
8e81f7c3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
7 deletions
+8
-7
analyticsclient/client.py
+3
-2
analyticsclient/course.py
+2
-2
analyticsclient/tests/test_course.py
+3
-3
No files found.
analyticsclient/client.py
View file @
fb9e563d
...
@@ -20,17 +20,18 @@ class Client(object):
...
@@ -20,17 +20,18 @@ class Client(object):
way to get access to those classes and their methods.
way to get access to those classes and their methods.
"""
"""
def
__init__
(
self
,
base_url
,
auth_token
=
None
):
def
__init__
(
self
,
base_url
,
auth_token
=
None
,
timeout
=
0.25
):
"""
"""
Initialize the client.
Initialize the client.
Arguments:
Arguments:
base_url (str): URL of the API server (e.g. http://analytics.edx.org/api/v0)
base_url (str): URL of the API server (e.g. http://analytics.edx.org/api/v0)
auth_token (str): Authentication token
auth_token (str): Authentication token
timeout (number): Maximum number of seconds during which all requests musts complete
"""
"""
self
.
base_url
=
base_url
.
rstrip
(
'/'
)
self
.
base_url
=
base_url
.
rstrip
(
'/'
)
self
.
auth_token
=
auth_token
self
.
auth_token
=
auth_token
self
.
timeout
=
0.1
self
.
timeout
=
timeout
self
.
status
=
Status
(
self
)
self
.
status
=
Status
(
self
)
self
.
courses
=
lambda
course_id
:
Course
(
self
,
course_id
)
self
.
courses
=
lambda
course_id
:
Course
(
self
,
course_id
)
...
...
analyticsclient/course.py
View file @
fb9e563d
...
@@ -24,7 +24,7 @@ class Course(object):
...
@@ -24,7 +24,7 @@ class Course(object):
Arguments:
Arguments:
demographic (str): Demographic by which enrollment data should be grouped.
demographic (str): Demographic by which enrollment data should be grouped.
"""
"""
return
self
.
client
.
get
(
'courses/{0}/enrollment/{1}'
.
format
(
self
.
course_id
,
demographic
))
return
self
.
client
.
get
(
'courses/{0}/enrollment/{1}
/
'
.
format
(
self
.
course_id
,
demographic
))
def
recent_activity
(
self
,
activity_type
=
at
.
ANY
):
def
recent_activity
(
self
,
activity_type
=
at
.
ANY
):
"""
"""
...
@@ -33,4 +33,4 @@ class Course(object):
...
@@ -33,4 +33,4 @@ class Course(object):
Arguments:
Arguments:
activity_type (str): The type of recent activity to return. Defaults to ANY.
activity_type (str): The type of recent activity to return. Defaults to ANY.
"""
"""
return
self
.
client
.
get
(
'courses/{0}/recent_activity?activity_type={1}'
.
format
(
self
.
course_id
,
activity_type
))
return
self
.
client
.
get
(
'courses/{0}/recent_activity
/
?activity_type={1}'
.
format
(
self
.
course_id
,
activity_type
))
analyticsclient/tests/test_course.py
View file @
fb9e563d
...
@@ -19,9 +19,9 @@ class CoursesTests(ClientTestCase):
...
@@ -19,9 +19,9 @@ class CoursesTests(ClientTestCase):
httpretty
.
disable
()
httpretty
.
disable
()
def
assertEnrollmentResponseData
(
self
,
course
,
data
,
demographic
=
None
):
def
assertEnrollmentResponseData
(
self
,
course
,
data
,
demographic
=
None
):
uri
=
self
.
get_api_url
(
'courses/{0}/enrollment'
.
format
(
course
.
course_id
))
uri
=
self
.
get_api_url
(
'courses/{0}/enrollment
/
'
.
format
(
course
.
course_id
))
if
demographic
:
if
demographic
:
uri
+=
'
/
%
s
'
%
demographic
uri
+=
'
%
s/
'
%
demographic
httpretty
.
register_uri
(
httpretty
.
GET
,
uri
,
body
=
json
.
dumps
(
data
))
httpretty
.
register_uri
(
httpretty
.
GET
,
uri
,
body
=
json
.
dumps
(
data
))
self
.
assertDictEqual
(
data
,
course
.
enrollment
(
demographic
))
self
.
assertDictEqual
(
data
,
course
.
enrollment
(
demographic
))
...
@@ -34,7 +34,7 @@ class CoursesTests(ClientTestCase):
...
@@ -34,7 +34,7 @@ class CoursesTests(ClientTestCase):
u'count'
:
200
,
u'count'
:
200
,
}
}
uri
=
self
.
get_api_url
(
'courses/{0}/recent_activity?activity_type={1}'
.
format
(
self
.
course_id
,
activity_type
))
uri
=
self
.
get_api_url
(
'courses/{0}/recent_activity
/
?activity_type={1}'
.
format
(
self
.
course_id
,
activity_type
))
httpretty
.
register_uri
(
httpretty
.
GET
,
uri
,
body
=
json
.
dumps
(
body
))
httpretty
.
register_uri
(
httpretty
.
GET
,
uri
,
body
=
json
.
dumps
(
body
))
self
.
assertDictEqual
(
body
,
self
.
course
.
recent_activity
(
activity_type
))
self
.
assertDictEqual
(
body
,
self
.
course
.
recent_activity
(
activity_type
))
...
...
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