Commit 77a2638d by Calen Pennington Committed by Nimisha Asthagiri

Move test_handle into the base class for schedule management command tests

parent f2ea6f66
......@@ -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):
......
......@@ -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)
......
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
)
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