diff --git a/openedx/core/djangoapps/schedules/management/commands/tests/test_send_recurring_nudge.py b/openedx/core/djangoapps/schedules/management/commands/tests/test_send_recurring_nudge.py index 37abeabdf2..520e02a859 100644 --- a/openedx/core/djangoapps/schedules/management/commands/tests/test_send_recurring_nudge.py +++ b/openedx/core/djangoapps/schedules/management/commands/tests/test_send_recurring_nudge.py @@ -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, diff --git a/openedx/core/djangoapps/schedules/management/commands/tests/test_send_upgrade_reminder.py b/openedx/core/djangoapps/schedules/management/commands/tests/test_send_upgrade_reminder.py index 9a91b1712b..dfff5b9ab3 100644 --- a/openedx/core/djangoapps/schedules/management/commands/tests/test_send_upgrade_reminder.py +++ b/openedx/core/djangoapps/schedules/management/commands/tests/test_send_upgrade_reminder.py @@ -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, diff --git a/openedx/core/djangoapps/schedules/management/commands/tests/tools.py b/openedx/core/djangoapps/schedules/management/commands/tests/tools.py index cb0248da5a..447d1ea83b 100644 --- a/openedx/core/djangoapps/schedules/management/commands/tests/tools.py +++ b/openedx/core/djangoapps/schedules/management/commands/tests/tools.py @@ -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)