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
77a2638d
Commit
77a2638d
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_handle into the base class for schedule management command tests
parent
f2ea6f66
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
23 deletions
+22
-23
openedx/core/djangoapps/schedules/management/commands/tests/test_send_recurring_nudge.py
+3
-12
openedx/core/djangoapps/schedules/management/commands/tests/test_send_upgrade_reminder.py
+1
-11
openedx/core/djangoapps/schedules/management/commands/tests/tools.py
+18
-0
No files found.
openedx/core/djangoapps/schedules/management/commands/tests/test_send_recurring_nudge.py
View file @
77a2638d
...
...
@@ -47,21 +47,12 @@ NUM_COURSE_MODES_QUERIES = 1
@skipUnless
(
'openedx.core.djangoapps.schedules.apps.SchedulesConfig'
in
settings
.
INSTALLED_APPS
,
"Can't test schedules if the app isn't installed"
)
class
TestSendRecurringNudge
(
ScheduleBaseEmailTestBase
):
__test__
=
True
# pylint: disable=protected-access
tested_task
=
tasks
.
ScheduleRecurringNudge
tested_command
=
nudge
.
Command
@patch.object
(
tested_command
,
'async_send_task'
)
def
test_handle
(
self
,
mock_send
):
test_day
=
datetime
.
datetime
(
2017
,
8
,
1
,
tzinfo
=
pytz
.
UTC
)
self
.
tested_command
()
.
handle
(
date
=
'2017-08-01'
,
site_domain_name
=
self
.
site_config
.
site
.
domain
)
for
day
in
(
-
3
,
-
10
):
mock_send
.
enqueue
.
assert_any_call
(
self
.
site_config
.
site
,
test_day
,
day
,
None
)
expected_offsets
=
(
-
3
,
-
10
)
@patch.object
(
tasks
,
'ace'
)
def
test_resolver_send
(
self
,
mock_ace
):
...
...
openedx/core/djangoapps/schedules/management/commands/tests/test_send_upgrade_reminder.py
View file @
77a2638d
...
...
@@ -64,6 +64,7 @@ class TestUpgradeReminder(ScheduleBaseEmailTestBase, SharedModuleStoreTestCase):
tested_task
=
tasks
.
ScheduleUpgradeReminder
tested_command
=
reminder
.
Command
expected_offsets
=
(
2
,)
@classmethod
def
setUpClass
(
cls
):
...
...
@@ -87,17 +88,6 @@ class TestUpgradeReminder(ScheduleBaseEmailTestBase, SharedModuleStoreTestCase):
expiration_datetime
=
datetime
.
datetime
.
now
(
pytz
.
UTC
)
+
datetime
.
timedelta
(
days
=
30
),
)
@patch.object
(
tested_command
,
'async_send_task'
)
def
test_handle
(
self
,
mock_send
):
test_day
=
datetime
.
datetime
(
2017
,
8
,
1
,
tzinfo
=
pytz
.
UTC
)
self
.
tested_command
()
.
handle
(
date
=
'2017-08-01'
,
site_domain_name
=
self
.
site_config
.
site
.
domain
)
mock_send
.
enqueue
.
assert_called_with
(
self
.
site_config
.
site
,
test_day
,
2
,
None
)
@patch.object
(
tasks
,
'ace'
)
def
test_resolver_send
(
self
,
mock_ace
):
current_day
=
datetime
.
datetime
(
2017
,
8
,
1
,
tzinfo
=
pytz
.
UTC
)
...
...
openedx/core/djangoapps/schedules/management/commands/tests/tools.py
View file @
77a2638d
import
datetime
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
...
...
@@ -21,3 +26,16 @@ class ScheduleBaseEmailTestBase(FilteredQueryCountMixin, CacheIsolationTestCase)
def
test_command_task_binding
(
self
):
self
.
assertEqual
(
self
.
tested_command
.
async_send_task
,
self
.
tested_task
)
def
test_handle
(
self
):
with
patch
.
object
(
self
.
tested_command
,
'async_send_task'
)
as
mock_send
:
test_day
=
datetime
.
datetime
(
2017
,
8
,
1
,
tzinfo
=
pytz
.
UTC
)
self
.
tested_command
()
.
handle
(
date
=
'2017-08-01'
,
site_domain_name
=
self
.
site_config
.
site
.
domain
)
for
offset
in
self
.
expected_offsets
:
mock_send
.
enqueue
.
assert_any_call
(
self
.
site_config
.
site
,
test_day
,
offset
,
None
)
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