Commit 55dfe940 by Calen Pennington

Add tests of the send_recurring_nudge

parent 662a2c23
......@@ -30,11 +30,11 @@ class RecurringNudge(MessageType):
class ScheduleStartResolver(RecipientResolver):
def __init__(self, target_start_date):
self.target_start_date = target_start_date
def __init__(self, current_date):
self.current_date = current_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)
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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment