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
5971ac6a
Commit
5971ac6a
authored
Dec 17, 2014
by
Clinton Blackburn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reorganized Tests
test_views was too big.
parent
ca57a8c4
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
101 additions
and
93 deletions
+101
-93
analytics_data_api/v0/tests/views/__init__.py
+0
-0
analytics_data_api/v0/tests/views/test_courses.py
+2
-93
analytics_data_api/v0/tests/views/test_problems.py
+99
-0
No files found.
analytics_data_api/v0/tests/views/__init__.py
0 → 100644
View file @
5971ac6a
analytics_data_api/v0/tests/
test_view
s.py
→
analytics_data_api/v0/tests/
views/test_course
s.py
View file @
5971ac6a
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
# NOTE: Full URLs are used throughout these tests to ensure that the API contract is fulfilled. The URLs should *not*
# NOTE: Full URLs are used throughout these tests to ensure that the API contract is fulfilled. The URLs should *not*
# change for versions greater than 1.0.0. Tests target a specific version of the API, additional tests should be added
# change for versions greater than 1.0.0. Tests target a specific version of the API, additional tests should be added
# for subsequent versions if there are breaking changes introduced in those versions.
# for subsequent versions if there are breaking changes introduced in those versions.
import
StringIO
import
StringIO
import
csv
import
csv
import
datetime
import
datetime
...
@@ -12,14 +13,11 @@ from django.conf import settings
...
@@ -12,14 +13,11 @@ from django.conf import settings
from
django_dynamic_fixture
import
G
from
django_dynamic_fixture
import
G
import
pytz
import
pytz
from
opaque_keys.edx.keys
import
CourseKey
from
opaque_keys.edx.keys
import
CourseKey
from
analytics_data_api.constants.country
import
get_country
from
analytics_data_api.constants.country
import
get_country
from
analytics_data_api.v0
import
models
from
analytics_data_api.v0
import
models
from
analytics_data_api.constants
import
country
,
enrollment_modes
,
genders
from
analytics_data_api.constants
import
country
,
enrollment_modes
,
genders
from
analytics_data_api.v0.models
import
CourseActivityWeekly
from
analytics_data_api.v0.models
import
CourseActivityWeekly
from
analytics_data_api.v0.serializers
import
ProblemResponseAnswerDistributionSerializer
from
analytics_data_api.v0.serializers
import
GradeDistributionSerializer
from
analytics_data_api.v0.serializers
import
SequentialOpenDistributionSerializer
from
analytics_data_api.v0.tests.utils
import
flatten
from
analytics_data_api.v0.tests.utils
import
flatten
from
analyticsdataserver.tests
import
TestCaseWithAuthentication
from
analyticsdataserver.tests
import
TestCaseWithAuthentication
...
@@ -390,37 +388,6 @@ class CourseEnrollmentByGenderViewTests(CourseEnrollmentViewTestCaseMixin, Defau
...
@@ -390,37 +388,6 @@ class CourseEnrollmentByGenderViewTests(CourseEnrollmentViewTestCaseMixin, Defau
self
.
assertViewReturnsExpectedData
(
expected
)
self
.
assertViewReturnsExpectedData
(
expected
)
# pylint: disable=no-member,no-value-for-parameter
class
AnswerDistributionTests
(
TestCaseWithAuthentication
):
path
=
'/answer_distribution/'
maxDiff
=
None
@classmethod
def
setUpClass
(
cls
):
cls
.
course_id
=
"org/num/run"
cls
.
module_id
=
"i4x://org/num/run/problem/RANDOMNUMBER"
cls
.
part_id1
=
"i4x-org-num-run-problem-RANDOMNUMBER_2_1"
cls
.
ad1
=
G
(
models
.
ProblemResponseAnswerDistribution
,
course_id
=
cls
.
course_id
,
module_id
=
cls
.
module_id
,
part_id
=
cls
.
part_id1
)
def
test_get
(
self
):
response
=
self
.
authenticated_get
(
'/api/v0/problems/
%
s
%
s'
%
(
self
.
module_id
,
self
.
path
))
self
.
assertEquals
(
response
.
status_code
,
200
)
expected_dict
=
ProblemResponseAnswerDistributionSerializer
(
self
.
ad1
)
.
data
actual_list
=
response
.
data
self
.
assertEquals
(
len
(
actual_list
),
1
)
self
.
assertDictEqual
(
actual_list
[
0
],
expected_dict
)
def
test_get_404
(
self
):
response
=
self
.
authenticated_get
(
'/api/v0/problems/
%
s
%
s'
%
(
"DOES-NOT-EXIST"
,
self
.
path
))
self
.
assertEquals
(
response
.
status_code
,
404
)
class
CourseEnrollmentViewTests
(
CourseEnrollmentViewTestCaseMixin
,
TestCaseWithAuthentication
):
class
CourseEnrollmentViewTests
(
CourseEnrollmentViewTestCaseMixin
,
TestCaseWithAuthentication
):
model
=
models
.
CourseEnrollmentDaily
model
=
models
.
CourseEnrollmentDaily
path
=
'/enrollment'
path
=
'/enrollment'
...
@@ -626,61 +593,3 @@ class CourseActivityWeeklyViewTests(CourseViewTestCaseMixin, TestCaseWithAuthent
...
@@ -626,61 +593,3 @@ class CourseActivityWeeklyViewTests(CourseViewTestCaseMixin, TestCaseWithAuthent
expected
=
self
.
format_as_response
(
*
self
.
model
.
objects
.
all
())
expected
=
self
.
format_as_response
(
*
self
.
model
.
objects
.
all
())
self
.
assertEqual
(
len
(
expected
),
2
)
self
.
assertEqual
(
len
(
expected
),
2
)
self
.
assertIntervalFilteringWorks
(
expected
,
self
.
interval_start
,
interval_end
+
datetime
.
timedelta
(
days
=
1
))
self
.
assertIntervalFilteringWorks
(
expected
,
self
.
interval_start
,
interval_end
+
datetime
.
timedelta
(
days
=
1
))
# pylint: disable=no-member,no-value-for-parameter
class
GradeDistributionTests
(
TestCaseWithAuthentication
):
path
=
'/grade_distribution/'
maxDiff
=
None
@classmethod
def
setUpClass
(
cls
):
cls
.
course_id
=
"org/class/test"
cls
.
module_id
=
"i4x://org/class/test/problem/RANDOM_NUMBER"
cls
.
ad1
=
G
(
models
.
GradeDistribution
,
course_id
=
cls
.
course_id
,
module_id
=
cls
.
module_id
,
)
def
test_get
(
self
):
response
=
self
.
authenticated_get
(
'/api/v0/problems/
%
s
%
s'
%
(
self
.
module_id
,
self
.
path
))
self
.
assertEquals
(
response
.
status_code
,
200
)
expected_dict
=
GradeDistributionSerializer
(
self
.
ad1
)
.
data
actual_list
=
response
.
data
self
.
assertEquals
(
len
(
actual_list
),
1
)
self
.
assertDictEqual
(
actual_list
[
0
],
expected_dict
)
def
test_get_404
(
self
):
response
=
self
.
authenticated_get
(
'/api/v0/problems/
%
s
%
s'
%
(
"DOES-NOT-EXIST"
,
self
.
path
))
self
.
assertEquals
(
response
.
status_code
,
404
)
# pylint: disable=no-member,no-value-for-parameter
class
SequentialOpenDistributionTests
(
TestCaseWithAuthentication
):
path
=
'/sequential_open_distribution/'
maxDiff
=
None
@classmethod
def
setUpClass
(
cls
):
cls
.
course_id
=
"org/class/test"
cls
.
module_id
=
"i4x://org/class/test/problem/RANDOM_NUMBER"
cls
.
ad1
=
G
(
models
.
SequentialOpenDistribution
,
course_id
=
cls
.
course_id
,
module_id
=
cls
.
module_id
,
)
def
test_get
(
self
):
response
=
self
.
authenticated_get
(
'/api/v0/problems/
%
s
%
s'
%
(
self
.
module_id
,
self
.
path
))
self
.
assertEquals
(
response
.
status_code
,
200
)
expected_dict
=
SequentialOpenDistributionSerializer
(
self
.
ad1
)
.
data
actual_list
=
response
.
data
self
.
assertEquals
(
len
(
actual_list
),
1
)
self
.
assertDictEqual
(
actual_list
[
0
],
expected_dict
)
def
test_get_404
(
self
):
response
=
self
.
authenticated_get
(
'/api/v0/problems/
%
s
%
s'
%
(
"DOES-NOT-EXIST"
,
self
.
path
))
self
.
assertEquals
(
response
.
status_code
,
404
)
analytics_data_api/v0/tests/views/test_problems.py
0 → 100644
View file @
5971ac6a
# coding=utf-8
# NOTE: Full URLs are used throughout these tests to ensure that the API contract is fulfilled. The URLs should *not*
# change for versions greater than 1.0.0. Tests target a specific version of the API, additional tests should be added
# for subsequent versions if there are breaking changes introduced in those versions.
# pylint: disable=no-member,no-value-for-parameter
from
django_dynamic_fixture
import
G
from
analytics_data_api.v0
import
models
from
analytics_data_api.v0.serializers
import
ProblemResponseAnswerDistributionSerializer
,
\
GradeDistributionSerializer
,
SequentialOpenDistributionSerializer
from
analyticsdataserver.tests
import
TestCaseWithAuthentication
class
AnswerDistributionTests
(
TestCaseWithAuthentication
):
path
=
'/answer_distribution/'
maxDiff
=
None
@classmethod
def
setUpClass
(
cls
):
cls
.
course_id
=
"org/num/run"
cls
.
module_id
=
"i4x://org/num/run/problem/RANDOMNUMBER"
cls
.
part_id1
=
"i4x-org-num-run-problem-RANDOMNUMBER_2_1"
cls
.
ad1
=
G
(
models
.
ProblemResponseAnswerDistribution
,
course_id
=
cls
.
course_id
,
module_id
=
cls
.
module_id
,
part_id
=
cls
.
part_id1
)
def
test_get
(
self
):
response
=
self
.
authenticated_get
(
'/api/v0/problems/
%
s
%
s'
%
(
self
.
module_id
,
self
.
path
))
self
.
assertEquals
(
response
.
status_code
,
200
)
expected_dict
=
ProblemResponseAnswerDistributionSerializer
(
self
.
ad1
)
.
data
actual_list
=
response
.
data
self
.
assertEquals
(
len
(
actual_list
),
1
)
self
.
assertDictEqual
(
actual_list
[
0
],
expected_dict
)
def
test_get_404
(
self
):
response
=
self
.
authenticated_get
(
'/api/v0/problems/
%
s
%
s'
%
(
"DOES-NOT-EXIST"
,
self
.
path
))
self
.
assertEquals
(
response
.
status_code
,
404
)
class
GradeDistributionTests
(
TestCaseWithAuthentication
):
path
=
'/grade_distribution/'
maxDiff
=
None
@classmethod
def
setUpClass
(
cls
):
cls
.
course_id
=
"org/class/test"
cls
.
module_id
=
"i4x://org/class/test/problem/RANDOM_NUMBER"
cls
.
ad1
=
G
(
models
.
GradeDistribution
,
course_id
=
cls
.
course_id
,
module_id
=
cls
.
module_id
,
)
def
test_get
(
self
):
response
=
self
.
authenticated_get
(
'/api/v0/problems/
%
s
%
s'
%
(
self
.
module_id
,
self
.
path
))
self
.
assertEquals
(
response
.
status_code
,
200
)
expected_dict
=
GradeDistributionSerializer
(
self
.
ad1
)
.
data
actual_list
=
response
.
data
self
.
assertEquals
(
len
(
actual_list
),
1
)
self
.
assertDictEqual
(
actual_list
[
0
],
expected_dict
)
def
test_get_404
(
self
):
response
=
self
.
authenticated_get
(
'/api/v0/problems/
%
s
%
s'
%
(
"DOES-NOT-EXIST"
,
self
.
path
))
self
.
assertEquals
(
response
.
status_code
,
404
)
class
SequentialOpenDistributionTests
(
TestCaseWithAuthentication
):
path
=
'/sequential_open_distribution/'
maxDiff
=
None
@classmethod
def
setUpClass
(
cls
):
cls
.
course_id
=
"org/class/test"
cls
.
module_id
=
"i4x://org/class/test/problem/RANDOM_NUMBER"
cls
.
ad1
=
G
(
models
.
SequentialOpenDistribution
,
course_id
=
cls
.
course_id
,
module_id
=
cls
.
module_id
,
)
def
test_get
(
self
):
response
=
self
.
authenticated_get
(
'/api/v0/problems/
%
s
%
s'
%
(
self
.
module_id
,
self
.
path
))
self
.
assertEquals
(
response
.
status_code
,
200
)
expected_dict
=
SequentialOpenDistributionSerializer
(
self
.
ad1
)
.
data
actual_list
=
response
.
data
self
.
assertEquals
(
len
(
actual_list
),
1
)
self
.
assertDictEqual
(
actual_list
[
0
],
expected_dict
)
def
test_get_404
(
self
):
response
=
self
.
authenticated_get
(
'/api/v0/problems/
%
s
%
s'
%
(
"DOES-NOT-EXIST"
,
self
.
path
))
self
.
assertEquals
(
response
.
status_code
,
404
)
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