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
OpenEdx
edx-platform
Commits
55dfe940
Commit
55dfe940
authored
Aug 14, 2017
by
Calen Pennington
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests of the send_recurring_nudge
parent
662a2c23
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
6 deletions
+23
-6
openedx/core/djangoapps/schedules/management/commands/send_recurring_nudge.py
+5
-6
openedx/core/djangoapps/schedules/management/commands/tests/__init__.py
+0
-0
openedx/core/djangoapps/schedules/management/commands/tests/test_send_recurring_nudge.py
+18
-0
No files found.
openedx/core/djangoapps/schedules/management/commands/send_recurring_nudge.py
View file @
55dfe940
...
...
@@ -30,11 +30,11 @@ class RecurringNudge(MessageType):
class
ScheduleStartResolver
(
RecipientResolver
):
def
__init__
(
self
,
target_star
t_date
):
self
.
target_start_date
=
target_star
t_date
def
__init__
(
self
,
curren
t_date
):
self
.
current_date
=
curren
t_date
def
send
(
self
,
week
):
schedule_day
.
delay
(
week
,
self
.
target_start_date
)
schedule_day
.
delay
(
week
,
self
.
current_date
-
datetime
.
timedelta
(
days
=
week
*
7
)
)
@task
...
...
@@ -121,7 +121,6 @@ class Command(BaseCommand):
def
handle
(
self
,
*
args
,
**
options
):
current_date
=
datetime
.
date
(
*
[
int
(
x
)
for
x
in
options
[
'date'
]
.
split
(
'-'
)])
resolver
=
ScheduleStartResolver
(
current_date
)
for
week
in
(
1
,
2
,
3
,
4
):
target_date
=
current_date
+
datetime
.
timedelta
(
days
=
week
*
7
)
ScheduleStartResolver
(
target_date
)
.
send
(
week
)
resolver
.
send
(
week
)
openedx/core/djangoapps/schedules/management/commands/tests/__init__.py
0 → 100644
View file @
55dfe940
openedx/core/djangoapps/schedules/management/commands/tests/test_send_recurring_nudge.py
0 → 100644
View file @
55dfe940
import
datetime
from
mock
import
patch
from
unittest
import
TestCase
from
openedx.core.djangoapps.schedules.management.commands
import
send_recurring_nudge
as
nudge
class
TestSendRecurringNudge
(
TestCase
):
@patch.object
(
nudge
,
'ScheduleStartResolver'
)
def
test_handle
(
self
,
mock_resolver
):
test_date
=
datetime
.
date
(
2017
,
8
,
1
)
nudge
.
Command
()
.
handle
(
date
=
test_date
.
isoformat
())
mock_resolver
.
assert_called_with
(
test_date
)
for
week
in
(
1
,
2
,
3
,
4
):
mock_resolver
()
.
send
.
assert_any_call
(
week
)
\ No newline at end of file
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