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
c4302df0
Commit
c4302df0
authored
Oct 25, 2017
by
Calen Pennington
Committed by
Nimisha Asthagiri
Oct 26, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move test_resolver_send into the schedule management command base test class
parent
77a2638d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
33 deletions
+21
-33
openedx/core/djangoapps/schedules/management/commands/tests/test_send_recurring_nudge.py
+0
-15
openedx/core/djangoapps/schedules/management/commands/tests/test_send_upgrade_reminder.py
+0
-18
openedx/core/djangoapps/schedules/management/commands/tests/tools.py
+21
-0
No files found.
openedx/core/djangoapps/schedules/management/commands/tests/test_send_recurring_nudge.py
View file @
c4302df0
...
...
@@ -54,21 +54,6 @@ class TestSendRecurringNudge(ScheduleBaseEmailTestBase):
tested_command
=
nudge
.
Command
expected_offsets
=
(
-
3
,
-
10
)
@patch.object
(
tasks
,
'ace'
)
def
test_resolver_send
(
self
,
mock_ace
):
current_day
=
datetime
.
datetime
(
2017
,
8
,
1
,
tzinfo
=
pytz
.
UTC
)
with
patch
.
object
(
self
.
tested_task
,
'apply_async'
)
as
mock_apply_async
:
self
.
tested_task
.
enqueue
(
self
.
site_config
.
site
,
current_day
,
-
3
)
test_day
=
current_day
+
datetime
.
timedelta
(
days
=-
3
)
mock_apply_async
.
assert_any_call
(
(
self
.
site_config
.
site
.
id
,
serialize
(
test_day
),
-
3
,
0
,
None
),
retry
=
False
,
)
mock_apply_async
.
assert_any_call
(
(
self
.
site_config
.
site
.
id
,
serialize
(
test_day
),
-
3
,
resolvers
.
RECURRING_NUDGE_NUM_BINS
-
1
,
None
),
retry
=
False
,
)
self
.
assertFalse
(
mock_ace
.
send
.
called
)
@ddt.data
(
1
,
10
,
100
)
@patch.object
(
tasks
,
'ace'
)
...
...
openedx/core/djangoapps/schedules/management/commands/tests/test_send_upgrade_reminder.py
View file @
c4302df0
...
...
@@ -88,24 +88,6 @@ class TestUpgradeReminder(ScheduleBaseEmailTestBase, SharedModuleStoreTestCase):
expiration_datetime
=
datetime
.
datetime
.
now
(
pytz
.
UTC
)
+
datetime
.
timedelta
(
days
=
30
),
)
@patch.object
(
tasks
,
'ace'
)
def
test_resolver_send
(
self
,
mock_ace
):
current_day
=
datetime
.
datetime
(
2017
,
8
,
1
,
tzinfo
=
pytz
.
UTC
)
test_day
=
current_day
+
datetime
.
timedelta
(
days
=
2
)
ScheduleFactory
.
create
(
upgrade_deadline
=
datetime
.
datetime
(
2017
,
8
,
3
,
15
,
34
,
30
,
tzinfo
=
pytz
.
UTC
))
with
patch
.
object
(
self
.
tested_task
,
'apply_async'
)
as
mock_apply_async
:
self
.
tested_task
.
enqueue
(
self
.
site_config
.
site
,
current_day
,
2
)
mock_apply_async
.
assert_any_call
(
(
self
.
site_config
.
site
.
id
,
serialize
(
test_day
),
2
,
0
,
None
),
retry
=
False
,
)
mock_apply_async
.
assert_any_call
(
(
self
.
site_config
.
site
.
id
,
serialize
(
test_day
),
2
,
resolvers
.
UPGRADE_REMINDER_NUM_BINS
-
1
,
None
),
retry
=
False
,
)
self
.
assertFalse
(
mock_ace
.
send
.
called
)
@ddt.data
(
1
,
10
,
100
)
@patch.object
(
tasks
,
'ace'
)
@patch.object
(
tested_task
,
'async_send_task'
)
...
...
openedx/core/djangoapps/schedules/management/commands/tests/tools.py
View file @
c4302df0
import
datetime
from
edx_ace.utils.date
import
serialize
from
mock
import
patch
import
pytz
from
courseware.models
import
DynamicUpgradeDeadlineConfiguration
from
openedx.core.djangolib.testing.utils
import
CacheIsolationTestCase
,
FilteredQueryCountMixin
from
openedx.core.djangoapps.site_configuration.tests.factories
import
SiteConfigurationFactory
,
SiteFactory
from
openedx.core.djangoapps.schedules
import
tasks
from
openedx.core.djangoapps.schedules.tests.factories
import
ScheduleConfigFactory
class
ScheduleBaseEmailTestBase
(
FilteredQueryCountMixin
,
CacheIsolationTestCase
):
__test__
=
False
...
...
@@ -39,3 +42,21 @@ class ScheduleBaseEmailTestBase(FilteredQueryCountMixin, CacheIsolationTestCase)
offset
,
None
)
@patch.object
(
tasks
,
'ace'
)
def
test_resolver_send
(
self
,
mock_ace
):
current_day
=
datetime
.
datetime
(
2017
,
8
,
1
,
tzinfo
=
pytz
.
UTC
)
offset
=
self
.
expected_offsets
[
0
]
target_day
=
current_day
+
datetime
.
timedelta
(
days
=
offset
)
with
patch
.
object
(
self
.
tested_task
,
'apply_async'
)
as
mock_apply_async
:
self
.
tested_task
.
enqueue
(
self
.
site_config
.
site
,
current_day
,
offset
)
mock_apply_async
.
assert_any_call
(
(
self
.
site_config
.
site
.
id
,
serialize
(
target_day
),
offset
,
0
,
None
),
retry
=
False
,
)
mock_apply_async
.
assert_any_call
(
(
self
.
site_config
.
site
.
id
,
serialize
(
target_day
),
offset
,
self
.
tested_task
.
num_bins
-
1
,
None
),
retry
=
False
,
)
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