Ejemplo n.º 1
0
 def test_doesnt_do_anything_on_the_weekend(
         self, FollowupsService, is_the_weekend):
     is_the_weekend.return_value = True
     command = send_followups.Command()
     command.stdout = Mock()
     command.handle()
     FollowupsService.assert_not_called()
Ejemplo n.º 2
0
 def test_expected_weekday_run(self, slack, is_the_weekend):
     is_the_weekend.return_value = False
     org = Organization.objects.get(slug='ebclc')
     dates = sorted([mock.get_old_date() for i in range(464, 469)])
     for date, pk in zip(dates, range(464, 469)):
         applicant = Applicant()
         applicant.save()
         factories.FormSubmissionWithOrgsFactory.create(
             id=pk,
             applicant=applicant,
             date_received=date,
             organizations=[org],
             answers=get_answers_for_orgs(
                 [org],
                 contact_preferences=[
                     'prefers_email',
                     'prefers_sms'],
                 phone='4445551111',
                 email='*****@*****.**',
             ))
     command = send_followups.Command()
     command.stdout = Mock()
     command.handle()
     self.assertEqual(
         len(slack.mock_calls), 1)
     self.assertEqual(
         len(self.notifications.email_followup.send.mock_calls), 4)
     self.assertEqual(
         len(self.notifications.slack_notification_sent.send.mock_calls), 4)
Ejemplo n.º 3
0
 def test_expected_weekday_run(self, is_the_weekend):
     is_the_weekend.return_value = False
     org = Organization.objects.get(slug='ebclc')
     dates = sorted([mock.get_old_date() for i in range(464, 469)])
     for date, pk in zip(dates, range(464, 469)):
         factories.FormSubmissionWithOrgsFactory.create(
             id=pk,
             date_received=date,
             organizations=[org],
             answers=get_answers_for_orgs(
                 [org],
                 contact_preferences=[
                     'prefers_email',
                     'prefers_sms'],
                 phone='4445551111',
                 email='*****@*****.**',
             ))
     command = send_followups.Command()
     command.stdout = Mock()
     with self.assertLogs(
             'project.services.logging_service', logging.INFO) as logs:
         command.handle()
     self.assertEqual(
         len(self.notifications.email_followup.send.mock_calls), 4)
     assertInLogsCount(logs, {'event_name=app_followup_sent': 4})