def delivery_summary_task(): """ last business day of month 3pm Tanzania time """ now = datetime.utcnow() last_business_day = get_business_day_of_month(month=now.month, year=now.year, count=-1) if now.day != last_business_day.day: return for domain in ILSGatewayConfig.get_all_enabled_domains(): for user in get_district_people(domain): send_translated_message( user, REMINDER_MONTHLY_DELIVERY_SUMMARY, **construct_delivery_summary(user.location) )
def test_negative_responses(self): script = """ 1235 > sijapokea 1236 > sijapokea 1237 > sijapokea """ self.run_script(script) with mock.patch('custom.ilsgateway.tanzania.reminders.reports.get_business_day_of_month_before', return_value=datetime.utcnow() - timedelta(days=1)): result = construct_delivery_summary(self.district) self.assertEqual(result["total"], 3) self.assertEqual(result["not_responding"], 0) self.assertEqual(result["not_received"], 3) self.assertEqual(result["received"], 0)
def test_basic_report_no_responses(self): result = construct_delivery_summary(self.district) self.assertEqual(result["total"], 3) self.assertEqual(result["not_responding"], 3) self.assertEqual(result["not_received"], 0) self.assertEqual(result["received"], 0)