Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
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-platform
Commits
02aae86b
Commit
02aae86b
authored
Oct 17, 2017
by
Gabe Mulley
Committed by
GitHub
Oct 17, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #16244 from edx/fix-flaky-test
fix flaky throttling test
parents
0ebeda25
34cc63d9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1 additions
and
40 deletions
+1
-40
common/djangoapps/enrollment/tests/test_views.py
+1
-40
No files found.
common/djangoapps/enrollment/tests/test_views.py
View file @
02aae86b
...
...
@@ -544,49 +544,10 @@ class EnrollmentTest(EnrollmentTestMixin, ModuleStoreTestCase, APITestCase, Ente
mode_display_name
=
CourseMode
.
DEFAULT_MODE_SLUG
,
)
for
attempt
in
xrange
(
self
.
rate_limit
+
10
):
for
attempt
in
xrange
(
self
.
rate_limit
+
2
):
expected_status
=
status
.
HTTP_429_TOO_MANY_REQUESTS
if
attempt
>=
self
.
rate_limit
else
status
.
HTTP_200_OK
self
.
assert_enrollment_status
(
expected_status
=
expected_status
)
def
test_enrollment_throttle_for_staff_user
(
self
):
""" Make sure throttle rate is higher for staff users """
self
.
rate_limit_config
.
enabled
=
True
self
.
rate_limit_config
.
save
()
self
.
client
.
logout
()
staff_user
=
UserFactory
.
create
(
password
=
self
.
PASSWORD
,
is_staff
=
True
)
self
.
client
.
login
(
username
=
staff_user
.
username
,
password
=
self
.
PASSWORD
)
CourseModeFactory
(
course_id
=
self
.
course
.
id
,
mode_slug
=
CourseMode
.
DEFAULT_MODE_SLUG
,
mode_display_name
=
CourseMode
.
DEFAULT_MODE_SLUG
,
)
throttle
=
EnrollmentUserThrottle
()
throttle
.
scope
=
'staff'
rate_limit
,
__
=
throttle
.
parse_rate
(
throttle
.
get_rate
())
# Make enough requests to reach the rate limit
for
attempt
in
xrange
(
rate_limit
):
self
.
assert_enrollment_status
(
username
=
staff_user
.
username
,
expected_status
=
status
.
HTTP_200_OK
)
# Once the limit is reached, subsequent requests should fail
for
attempt
in
xrange
(
rate_limit
+
50
):
self
.
assert_enrollment_status
(
username
=
staff_user
.
username
,
expected_status
=
status
.
HTTP_429_TOO_MANY_REQUESTS
)
def
test_enrollment_throttle_for_service
(
self
):
"""Make sure a service can call the enrollment API as many times as needed. """
self
.
rate_limit_config
.
enabled
=
True
self
.
rate_limit_config
.
save
()
CourseModeFactory
.
create
(
course_id
=
self
.
course
.
id
,
mode_slug
=
CourseMode
.
DEFAULT_MODE_SLUG
,
mode_display_name
=
CourseMode
.
DEFAULT_MODE_SLUG
,
)
for
__
in
xrange
(
self
.
rate_limit
+
10
):
self
.
assert_enrollment_status
(
as_server
=
True
)
def
test_create_enrollment_with_mode
(
self
):
"""With the right API key, create a new enrollment with a mode set other than the default."""
# Create a professional ed course mode.
...
...
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