Commit 0f102323 by Calen Pennington

Use official celery interfaces for class-based tasks

parent 505e0396
......@@ -110,7 +110,7 @@ class TestSendRecurringNudge(FilteredQueryCountMixin, CacheIsolationTestCase):
expected_queries += NUM_COURSE_MODES_QUERIES
with self.assertNumQueries(expected_queries, table_blacklist=WAFFLE_TABLES):
tasks.ScheduleRecurringNudge().run(
tasks.ScheduleRecurringNudge.delay(
self.site_config.site.id, target_day_str=test_datetime_str, day_offset=-3, bin_num=b,
org_list=[schedules[0].enrollment.course.org],
)
......@@ -130,7 +130,7 @@ class TestSendRecurringNudge(FilteredQueryCountMixin, CacheIsolationTestCase):
test_datetime_str = serialize(test_datetime)
for b in range(resolvers.RECURRING_NUDGE_NUM_BINS):
with self.assertNumQueries(NUM_QUERIES_NO_MATCHING_SCHEDULES, table_blacklist=WAFFLE_TABLES):
tasks.ScheduleRecurringNudge().run(
tasks.ScheduleRecurringNudge.delay(
self.site_config.site.id, target_day_str=test_datetime_str, day_offset=-3, bin_num=b,
org_list=[schedule.enrollment.course.org],
)
......@@ -228,7 +228,7 @@ class TestSendRecurringNudge(FilteredQueryCountMixin, CacheIsolationTestCase):
test_datetime = datetime.datetime(2017, 8, 3, 17, tzinfo=pytz.UTC)
test_datetime_str = serialize(test_datetime)
with self.assertNumQueries(NUM_QUERIES_WITH_MATCHES, table_blacklist=WAFFLE_TABLES):
tasks.ScheduleRecurringNudge().run(
tasks.ScheduleRecurringNudge.delay(
limited_config.site.id, target_day_str=test_datetime_str, day_offset=-3, bin_num=0,
org_list=org_list, exclude_orgs=exclude_orgs,
)
......@@ -252,7 +252,7 @@ class TestSendRecurringNudge(FilteredQueryCountMixin, CacheIsolationTestCase):
test_datetime = datetime.datetime(2017, 8, 3, 19, 44, 30, tzinfo=pytz.UTC)
test_datetime_str = serialize(test_datetime)
with self.assertNumQueries(NUM_QUERIES_WITH_MATCHES, table_blacklist=WAFFLE_TABLES):
tasks.ScheduleRecurringNudge().run(
tasks.ScheduleRecurringNudge.delay(
self.site_config.site.id, target_day_str=test_datetime_str, day_offset=-3,
bin_num=user.id % resolvers.RECURRING_NUDGE_NUM_BINS,
org_list=[schedules[0].enrollment.course.org],
......@@ -291,7 +291,7 @@ class TestSendRecurringNudge(FilteredQueryCountMixin, CacheIsolationTestCase):
mock_schedule_send.apply_async = lambda args, *_a, **_kw: sent_messages.append(args)
with self.assertNumQueries(NUM_QUERIES_WITH_MATCHES, table_blacklist=WAFFLE_TABLES):
tasks.ScheduleRecurringNudge().run(
tasks.ScheduleRecurringNudge.delay(
self.site_config.site.id, target_day_str=test_datetime_str, day_offset=day,
bin_num=self._calculate_bin_for_user(user), org_list=[schedules[0].enrollment.course.org],
)
......@@ -425,7 +425,7 @@ class TestSendRecurringNudge(FilteredQueryCountMixin, CacheIsolationTestCase):
mock_schedule_send.apply_async = lambda args, *_a, **_kw: sent_messages.append(args)
bin_task().run(
bin_task.delay(
self.site_config.site.id,
target_day_str=bin_task_params[0],
day_offset=bin_task_params[1],
......
......@@ -114,7 +114,7 @@ class TestUpgradeReminder(FilteredQueryCountMixin, CacheIsolationTestCase):
expected_queries += NUM_COURSE_MODES_QUERIES
with self.assertNumQueries(expected_queries, table_blacklist=WAFFLE_TABLES):
tasks.ScheduleUpgradeReminder().run(
tasks.ScheduleUpgradeReminder.delay(
self.site_config.site.id, target_day_str=test_datetime_str, day_offset=2, bin_num=b,
org_list=[schedules[0].enrollment.course.org],
)
......@@ -135,7 +135,7 @@ class TestUpgradeReminder(FilteredQueryCountMixin, CacheIsolationTestCase):
test_datetime_str = serialize(test_datetime)
for b in range(resolvers.UPGRADE_REMINDER_NUM_BINS):
with self.assertNumQueries(NUM_QUERIES_NO_MATCHING_SCHEDULES, table_blacklist=WAFFLE_TABLES):
tasks.ScheduleUpgradeReminder().run(
tasks.ScheduleUpgradeReminder.delay(
self.site_config.site.id, target_day_str=test_datetime_str, day_offset=2, bin_num=b,
org_list=[schedule.enrollment.course.org],
)
......@@ -211,7 +211,7 @@ class TestUpgradeReminder(FilteredQueryCountMixin, CacheIsolationTestCase):
test_datetime = datetime.datetime(2017, 8, 3, 17, tzinfo=pytz.UTC)
test_datetime_str = serialize(test_datetime)
with self.assertNumQueries(NUM_QUERIES_WITH_MATCHES, table_blacklist=WAFFLE_TABLES):
tasks.ScheduleUpgradeReminder().run(
tasks.ScheduleUpgradeReminder.delay(
limited_config.site.id, target_day_str=test_datetime_str, day_offset=2, bin_num=0,
org_list=org_list, exclude_orgs=exclude_orgs,
)
......@@ -235,7 +235,7 @@ class TestUpgradeReminder(FilteredQueryCountMixin, CacheIsolationTestCase):
test_datetime = datetime.datetime(2017, 8, 3, 19, 44, 30, tzinfo=pytz.UTC)
test_datetime_str = serialize(test_datetime)
with self.assertNumQueries(NUM_QUERIES_WITH_MATCHES, table_blacklist=WAFFLE_TABLES):
tasks.ScheduleUpgradeReminder().run(
tasks.ScheduleUpgradeReminder.delay(
self.site_config.site.id, target_day_str=test_datetime_str, day_offset=2,
bin_num=user.id % resolvers.UPGRADE_REMINDER_NUM_BINS,
org_list=[schedules[0].enrollment.course.org],
......@@ -290,7 +290,7 @@ class TestUpgradeReminder(FilteredQueryCountMixin, CacheIsolationTestCase):
# since we create a new course for each schedule in this test, we expect there to be one per message
num_expected_queries = NUM_QUERIES_WITH_MATCHES + NUM_QUERIES_WITH_DEADLINE
with self.assertNumQueries(num_expected_queries, table_blacklist=WAFFLE_TABLES):
tasks.ScheduleUpgradeReminder().run(
tasks.ScheduleUpgradeReminder.delay(
self.site_config.site.id, target_day_str=test_datetime_str, day_offset=day,
bin_num=self._calculate_bin_for_user(user),
org_list=[schedules[0].enrollment.course.org],
......
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