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
77c70aa1
Commit
77c70aa1
authored
Aug 28, 2014
by
Clinton Blackburn
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #20 from edx/coverage-improvement
Added additional test coverage
parents
3b5d855b
9dbbf204
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
5 deletions
+25
-5
analytics_data_api/v0/tests/test_views.py
+11
-5
analyticsdataserver/tests.py
+14
-0
No files found.
analytics_data_api/v0/tests/test_views.py
View file @
77c70aa1
...
...
@@ -41,6 +41,12 @@ class CourseActivityLastWeekTest(TestCaseWithAuthentication):
self
.
assertEquals
(
response
.
status_code
,
200
)
self
.
assertEquals
(
response
.
data
,
self
.
get_activity_record
())
def
assertValidActivityResponse
(
self
,
activity_type
,
count
):
response
=
self
.
authenticated_get
(
'/api/v0/courses/{0}/recent_activity?activity_type={1}'
.
format
(
self
.
course_id
,
activity_type
))
self
.
assertEquals
(
response
.
status_code
,
200
)
self
.
assertEquals
(
response
.
data
,
self
.
get_activity_record
(
activity_type
=
activity_type
,
count
=
count
))
@staticmethod
def
get_activity_record
(
**
kwargs
):
default
=
{
...
...
@@ -63,12 +69,12 @@ class CourseActivityLastWeekTest(TestCaseWithAuthentication):
self
.
assertEquals
(
response
.
status_code
,
200
)
self
.
assertEquals
(
response
.
data
,
self
.
get_activity_record
())
def
test_any_activity
(
self
):
self
.
assertValidActivityResponse
(
'ANY'
,
300
)
self
.
assertValidActivityResponse
(
'any'
,
300
)
def
test_video_activity
(
self
):
activity_type
=
'played_video'
response
=
self
.
authenticated_get
(
'/api/v0/courses/{0}/recent_activity?activity_type={1}'
.
format
(
self
.
course_id
,
activity_type
))
self
.
assertEquals
(
response
.
status_code
,
200
)
self
.
assertEquals
(
response
.
data
,
self
.
get_activity_record
(
activity_type
=
activity_type
,
count
=
400
))
self
.
assertValidActivityResponse
(
'played_video'
,
400
)
def
test_unknown_activity
(
self
):
activity_type
=
'missing_activity_type'
...
...
analyticsdataserver/tests.py
View file @
77c70aa1
...
...
@@ -8,6 +8,8 @@ from django.test.utils import override_settings
import
mock
from
rest_framework.authtoken.models
import
Token
from
analytics_data_api.v0.models
import
CourseEnrollmentDaily
,
CourseEnrollmentByBirthYear
from
analyticsdataserver.router
import
AnalyticsApiRouter
class
TestCaseWithAuthentication
(
TestCase
):
...
...
@@ -83,3 +85,15 @@ class OperationalEndpointsTest(TestCaseWithAuthentication):
# This would normally return UNAVAILABLE, however we have deleted the settings so it will use the default
# connection which should be OK.
self
.
assert_database_health
(
'OK'
)
class
AnalyticsApiRouterTests
(
TestCase
):
def
setUp
(
self
):
self
.
router
=
AnalyticsApiRouter
()
def
test_allow_relation
(
self
):
"""
Relations should only be allowed for objects contained within the same database.
"""
self
.
assertFalse
(
self
.
router
.
allow_relation
(
CourseEnrollmentDaily
,
User
))
self
.
assertTrue
(
self
.
router
.
allow_relation
(
CourseEnrollmentDaily
,
CourseEnrollmentByBirthYear
))
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