Commit f2ea6f66 by Calen Pennington Committed by Nimisha Asthagiri

Move the tested_command up to a class attribute, and make sure that it matches with the tested_task

parent c4249c6b
......@@ -49,11 +49,12 @@ NUM_COURSE_MODES_QUERIES = 1
class TestSendRecurringNudge(ScheduleBaseEmailTestBase):
# pylint: disable=protected-access
tested_task = tasks.ScheduleRecurringNudge
tested_command = nudge.Command
@patch.object(nudge.Command, 'async_send_task')
@patch.object(tested_command, 'async_send_task')
def test_handle(self, mock_send):
test_day = datetime.datetime(2017, 8, 1, tzinfo=pytz.UTC)
nudge.Command().handle(date='2017-08-01', site_domain_name=self.site_config.site.domain)
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,
......
......@@ -60,8 +60,10 @@ LOG = logging.getLogger(__name__)
"Can't test schedules if the app isn't installed")
@freeze_time('2017-08-01 00:00:00', tz_offset=0, tick=True)
class TestUpgradeReminder(ScheduleBaseEmailTestBase, SharedModuleStoreTestCase):
__test__ = True
tested_task = tasks.ScheduleUpgradeReminder
tested_command = reminder.Command
@classmethod
def setUpClass(cls):
......@@ -85,10 +87,10 @@ class TestUpgradeReminder(ScheduleBaseEmailTestBase, SharedModuleStoreTestCase):
expiration_datetime=datetime.datetime.now(pytz.UTC) + datetime.timedelta(days=30),
)
@patch.object(reminder.Command, 'async_send_task')
@patch.object(tested_command, 'async_send_task')
def test_handle(self, mock_send):
test_day = datetime.datetime(2017, 8, 1, tzinfo=pytz.UTC)
reminder.Command().handle(date='2017-08-01', site_domain_name=self.site_config.site.domain)
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,
......
......@@ -6,6 +6,8 @@ from openedx.core.djangoapps.schedules.tests.factories import ScheduleConfigFact
class ScheduleBaseEmailTestBase(FilteredQueryCountMixin, CacheIsolationTestCase):
__test__ = False
ENABLED_CACHES = ['default']
def setUp(self):
......@@ -16,3 +18,6 @@ class ScheduleBaseEmailTestBase(FilteredQueryCountMixin, CacheIsolationTestCase)
ScheduleConfigFactory.create(site=self.site_config.site)
DynamicUpgradeDeadlineConfiguration.objects.create(enabled=True)
def test_command_task_binding(self):
self.assertEqual(self.tested_command.async_send_task, self.tested_task)
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