Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hsin-Yu Chien
edx-platform-release
Commits
af1a7ca2
Commit
af1a7ca2
authored
4 years ago
by
Daphne Li-Chen
Browse files
Options
Downloads
Patches
Plain Diff
AA-204: adding tests
parent
6f8ecf33
Loading
Loading
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lms/djangoapps/course_home_api/progress/v1/tests/__init__.py
+0
-0
0 additions, 0 deletions
lms/djangoapps/course_home_api/progress/v1/tests/__init__.py
lms/djangoapps/course_home_api/progress/v1/tests/test_views.py
+68
-0
68 additions, 0 deletions
...jangoapps/course_home_api/progress/v1/tests/test_views.py
with
68 additions
and
0 deletions
lms/djangoapps/course_home_api/progress/v1/tests/__init__.py
0 → 100644
+
0
−
0
View file @
af1a7ca2
This diff is collapsed.
Click to expand it.
lms/djangoapps/course_home_api/progress/v1/tests/test_views.py
0 → 100644
+
68
−
0
View file @
af1a7ca2
"""
Tests for Progress Tab API in the Course Home API
"""
from
datetime
import
datetime
import
ddt
from
django.urls
import
reverse
from
course_modes.models
import
CourseMode
from
lms.djangoapps.course_home_api.tests.utils
import
BaseCourseHomeTests
from
lms.djangoapps.course_home_api.toggles
import
COURSE_HOME_MICROFRONTEND
from
openedx.features.content_type_gating.models
import
ContentTypeGatingConfig
from
openedx.core.djangoapps.user_api.preferences.api
import
set_user_preference
from
openedx.core.djangoapps.waffle_utils.testutils
import
override_waffle_flag
from
student.models
import
CourseEnrollment
from
student.tests.factories
import
UserFactory
@override_waffle_flag
(
COURSE_HOME_MICROFRONTEND
,
active
=
True
)
@ddt.ddt
class
ProgressTabTestViews
(
BaseCourseHomeTests
):
"""
Tests for the Progress Tab API
"""
def
setUp
(
self
):
super
().
setUp
()
self
.
url
=
reverse
(
'
course-home-progress-tab
'
,
args
=
[
self
.
course
.
id
])
ContentTypeGatingConfig
.
objects
.
create
(
enabled
=
True
,
enabled_as_of
=
datetime
(
2017
,
1
,
1
))
@ddt.data
(
CourseMode
.
AUDIT
,
CourseMode
.
VERIFIED
)
def
test_get_authenticated_enrolled_user
(
self
,
enrollment_mode
):
CourseEnrollment
.
enroll
(
self
.
user
,
self
.
course
.
id
,
enrollment_mode
)
response
=
self
.
client
.
get
(
self
.
url
)
self
.
assertEqual
(
response
.
status_code
,
200
)
# Pulling out the date blocks to check learner has access.
self
.
assertNotEqual
(
response
.
data
[
'
courseware_summary
'
],
None
)
for
chapter
in
response
.
data
[
'
courseware_summary
'
]:
self
.
assertNotEqual
(
chapter
,
None
)
def
test_get_authenticated_user_not_enrolled
(
self
):
response
=
self
.
client
.
get
(
self
.
url
)
# expecting a redirect
self
.
assertEqual
(
response
.
status_code
,
302
)
def
test_get_unauthenticated_user
(
self
):
self
.
client
.
logout
()
response
=
self
.
client
.
get
(
self
.
url
)
self
.
assertEqual
(
response
.
status_code
,
403
)
def
test_get_unknown_course
(
self
):
url
=
reverse
(
'
course-home-progress-tab
'
,
args
=
[
'
course-v1:unknown+course+2T2020
'
])
response
=
self
.
client
.
get
(
url
)
self
.
assertEqual
(
response
.
status_code
,
404
)
def
test_masquerade
(
self
):
user
=
UserFactory
()
set_user_preference
(
user
,
'
time_zone
'
,
'
Asia/Tokyo
'
)
CourseEnrollment
.
enroll
(
user
,
self
.
course
.
id
)
self
.
switch_to_staff
()
# needed for masquerade
# Sanity check on our normal user
self
.
assertEqual
(
self
.
client
.
get
(
self
.
url
).
data
[
'
user_timezone
'
],
None
)
# Now switch users and confirm we get a different result
self
.
update_masquerade
(
username
=
user
.
username
)
self
.
assertEqual
(
self
.
client
.
get
(
self
.
url
).
data
[
'
user_timezone
'
],
'
Asia/Tokyo
'
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment