Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
code.vt.edu will be down for maintenance from 0530-0630 EDT Wednesday, March 26th
Show more breadcrumbs
Hsin-Yu Chien
edx-platform-release
Commits
1198e5f2
Unverified
Commit
1198e5f2
authored
5 years ago
by
Jeremy Bowman
Committed by
GitHub
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Fix intermittent unit test failures (#20783)
parent
765559c7
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
openedx/core/djangoapps/schedules/management/commands/tests/send_email_base.py
+17
-3
17 additions, 3 deletions
...ps/schedules/management/commands/tests/send_email_base.py
with
17 additions
and
3 deletions
openedx/core/djangoapps/schedules/management/commands/tests/send_email_base.py
+
17
−
3
View file @
1198e5f2
...
...
@@ -12,6 +12,8 @@ import attr
import
ddt
import
pytz
from
django.conf
import
settings
from
django.contrib.auth.models
import
User
from
django.db.models
import
Max
from
edx_ace.channel
import
ChannelMap
,
ChannelType
from
edx_ace.test_utils
import
StubPolicy
,
patch_policies
from
edx_ace.utils.date
import
serialize
...
...
@@ -105,6 +107,18 @@ class ScheduleSendEmailTestMixin(FilteredQueryCountMixin):
def
_calculate_bin_for_user
(
self
,
user
):
return
user
.
id
%
self
.
task
.
num_bins
def
_next_user_id
(
self
):
"""
Get the next user ID which is a multiple of the bin count and greater
than the current largest user ID. Avoids intermittent ID collisions
with the user created in ModuleStoreTestCase.setUp().
"""
max_user_id
=
User
.
objects
.
aggregate
(
Max
(
'
id
'
))[
'
id__max
'
]
if
max_user_id
is
None
:
max_user_id
=
0
num_bins
=
self
.
task
.
num_bins
return
max_user_id
+
num_bins
-
(
max_user_id
%
num_bins
)
def
_get_dates
(
self
,
offset
=
None
):
current_day
=
_get_datetime_beginning_of_day
(
datetime
.
datetime
.
now
(
pytz
.
UTC
))
offset
=
offset
or
self
.
expected_offsets
[
0
]
...
...
@@ -296,8 +310,8 @@ class ScheduleSendEmailTestMixin(FilteredQueryCountMixin):
for
config
in
(
this_config
,
other_config
):
ScheduleConfigFactory
.
create
(
site
=
config
.
site
)
user1
=
UserFactory
.
create
(
id
=
self
.
task
.
num_bins
)
user2
=
UserFactory
.
create
(
id
=
self
.
task
.
num_bins
*
2
)
user1
=
UserFactory
.
create
(
id
=
self
.
_next_user_id
()
)
user2
=
UserFactory
.
create
(
id
=
user1
.
id
+
self
.
task
.
num_bins
)
current_day
,
offset
,
target_day
,
upgrade_deadline
=
self
.
_get_dates
()
self
.
_schedule_factory
(
...
...
@@ -323,7 +337,7 @@ class ScheduleSendEmailTestMixin(FilteredQueryCountMixin):
@ddt.data
(
True
,
False
)
def
test_course_end
(
self
,
has_course_ended
):
user1
=
UserFactory
.
create
(
id
=
self
.
task
.
num_bins
)
user1
=
UserFactory
.
create
(
id
=
self
.
_next_user_id
()
)
current_day
,
offset
,
target_day
,
upgrade_deadline
=
self
.
_get_dates
()
end_date_offset
=
-
2
if
has_course_ended
else
2
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
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