'Tests sending emails with or without failures'

def check_emails_sent(self, num_emails, task_history_request, with_failures=False):

    response = self.get_email_content_response(num_emails, task_history_request, with_failures)
    self.assertTrue(task_history_request.called)
    expected_email_info = [email_info.to_dict() for email_info in self.emails_info.values()]
    actual_email_info = json.loads(response.content)['emails']
    self.assertEqual(len(actual_email_info), num_emails)
    for (exp_email, act_email) in zip(expected_email_info, actual_email_info):
        self.assertDictEqual(exp_email, act_email)
    self.assertEqual(expected_email_info, actual_email_info)
