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
1ad8cd01
Commit
1ad8cd01
authored
Oct 26, 2017
by
Nimisha Asthagiri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move test_multiple_enrollments into the schedules management command base test class
parent
b852025a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
53 deletions
+25
-53
openedx/core/djangoapps/schedules/management/commands/tests/test_send_recurring_nudge.py
+0
-23
openedx/core/djangoapps/schedules/management/commands/tests/test_send_upgrade_reminder.py
+0
-30
openedx/core/djangoapps/schedules/management/commands/tests/tools.py
+25
-0
No files found.
openedx/core/djangoapps/schedules/management/commands/tests/test_send_recurring_nudge.py
View file @
1ad8cd01
...
...
@@ -57,29 +57,6 @@ class TestSendRecurringNudge(ScheduleBaseEmailTestBase):
enqueue_config
=
'enqueue_recurring_nudge'
expected_offsets
=
(
-
3
,
-
10
)
@patch.object
(
tasks
,
'ace'
)
@patch.object
(
tested_task
,
'async_send_task'
)
def
test_multiple_enrollments
(
self
,
mock_schedule_send
,
mock_ace
):
user
=
UserFactory
.
create
()
schedules
=
[
ScheduleFactory
.
create
(
start
=
datetime
.
datetime
(
2017
,
8
,
3
,
19
,
44
,
30
,
tzinfo
=
pytz
.
UTC
),
enrollment__user
=
user
,
enrollment__course__id
=
CourseLocator
(
'edX'
,
'toy'
,
'Course{}'
.
format
(
course_num
))
)
for
course_num
in
(
1
,
2
,
3
)
]
test_datetime
=
datetime
.
datetime
(
2017
,
8
,
3
,
19
,
44
,
30
,
tzinfo
=
pytz
.
UTC
)
test_datetime_str
=
serialize
(
test_datetime
)
with
self
.
assertNumQueries
(
NUM_QUERIES_WITH_MATCHES
+
NUM_QUERIES_NO_ORG_LIST
,
table_blacklist
=
WAFFLE_TABLES
):
self
.
tested_task
.
apply
(
kwargs
=
dict
(
site_id
=
self
.
site_config
.
site
.
id
,
target_day_str
=
test_datetime_str
,
day_offset
=-
3
,
bin_num
=
user
.
id
%
resolvers
.
RECURRING_NUDGE_NUM_BINS
,
))
self
.
assertEqual
(
mock_schedule_send
.
apply_async
.
call_count
,
1
)
self
.
assertFalse
(
mock_ace
.
send
.
called
)
@ddt.data
(
*
itertools
.
product
((
1
,
10
,
100
),
(
-
3
,
-
10
)))
@ddt.unpack
def
test_templates
(
self
,
message_count
,
day
):
...
...
openedx/core/djangoapps/schedules/management/commands/tests/test_send_upgrade_reminder.py
View file @
1ad8cd01
...
...
@@ -75,36 +75,6 @@ class TestUpgradeReminder(ScheduleBaseEmailTestBase):
expiration_datetime
=
datetime
.
datetime
.
now
(
pytz
.
UTC
)
+
datetime
.
timedelta
(
days
=
30
),
)
@patch.object
(
tasks
,
'ace'
)
@patch.object
(
tested_task
,
'async_send_task'
)
def
test_multiple_enrollments
(
self
,
mock_schedule_send
,
mock_ace
):
user
=
UserFactory
.
create
()
schedules
=
[
ScheduleFactory
.
create
(
upgrade_deadline
=
datetime
.
datetime
(
2017
,
8
,
3
,
19
,
44
,
30
,
tzinfo
=
pytz
.
UTC
),
enrollment__user
=
user
,
enrollment__course__self_paced
=
True
,
enrollment__course__id
=
CourseLocator
(
'edX'
,
'toy'
,
'Course{}'
.
format
(
course_num
))
)
for
course_num
in
(
1
,
2
,
3
)
]
course_switch_queries
=
len
(
set
(
s
.
enrollment
.
course
.
id
for
s
in
schedules
))
org_switch_queries
=
len
(
set
(
s
.
enrollment
.
course
.
id
.
org
for
s
in
schedules
))
test_datetime
=
datetime
.
datetime
(
2017
,
8
,
3
,
19
,
44
,
30
,
tzinfo
=
pytz
.
UTC
)
test_datetime_str
=
serialize
(
test_datetime
)
expected_query_count
=
(
NUM_QUERIES_FIRST_MATCH
+
course_switch_queries
+
org_switch_queries
+
NUM_QUERIES_NO_ORG_LIST
)
with
self
.
assertNumQueries
(
expected_query_count
,
table_blacklist
=
WAFFLE_TABLES
):
self
.
tested_task
.
apply
(
kwargs
=
dict
(
site_id
=
self
.
site_config
.
site
.
id
,
target_day_str
=
test_datetime_str
,
day_offset
=
2
,
bin_num
=
self
.
_calculate_bin_for_user
(
user
),
))
self
.
assertEqual
(
mock_schedule_send
.
apply_async
.
call_count
,
1
)
self
.
assertFalse
(
mock_ace
.
send
.
called
)
@ddt.data
(
1
,
10
,
100
)
def
test_templates
(
self
,
message_count
):
now
=
datetime
.
datetime
.
now
(
pytz
.
UTC
)
...
...
openedx/core/djangoapps/schedules/management/commands/tests/tools.py
View file @
1ad8cd01
...
...
@@ -291,3 +291,28 @@ class ScheduleBaseEmailTestBase(SharedModuleStoreTestCase):
self
.
assertFalse
(
mock_schedule_send
.
apply_async
.
called
)
else
:
self
.
assertTrue
(
mock_schedule_send
.
apply_async
.
called
)
@patch.object
(
tasks
,
'ace'
)
def
test_multiple_enrollments
(
self
,
mock_ace
):
user
=
UserFactory
.
create
()
current_day
,
offset
,
target_day
=
self
.
_get_dates
()
num_courses
=
3
for
course_index
in
range
(
num_courses
):
ScheduleFactory
.
create
(
start
=
target_day
,
upgrade_deadline
=
target_day
,
enrollment__course__self_paced
=
True
,
enrollment__user
=
user
,
enrollment__course__id
=
CourseKey
.
from_string
(
'edX/toy/course{}'
.
format
(
course_index
))
)
course_queries
=
num_courses
if
self
.
has_course_queries
else
0
expected_query_count
=
NUM_QUERIES_FIRST_MATCH
+
course_queries
+
NUM_QUERIES_NO_ORG_LIST
with
self
.
assertNumQueries
(
expected_query_count
,
table_blacklist
=
WAFFLE_TABLES
):
with
patch
.
object
(
self
.
tested_task
,
'async_send_task'
)
as
mock_schedule_send
:
self
.
tested_task
.
apply
(
kwargs
=
dict
(
site_id
=
self
.
site_config
.
site
.
id
,
target_day_str
=
serialize
(
target_day
),
day_offset
=
offset
,
bin_num
=
self
.
_calculate_bin_for_user
(
user
),
))
self
.
assertEqual
(
mock_schedule_send
.
apply_async
.
call_count
,
1
)
self
.
assertFalse
(
mock_ace
.
send
.
called
)
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