'Assert that a certificate was generated with the correct mode and
template type.'

def assert_certificate_generated(self, mock_send, expected_mode, expected_template_name):

    self.assertTrue(mock_send.called)
    (__, kwargs) = mock_send.call_args_list[0]
    actual_header = json.loads(kwargs['header'])
    self.assertIn('https://edx.org/update_certificate?key=', actual_header['lms_callback_url'])
    body = json.loads(kwargs['body'])
    self.assertIn(expected_template_name, body['template_pdf'])
    certificate = GeneratedCertificate.eligible_certificates.get(user=self.user_2, course_id=self.course.id)
    self.assertEqual(certificate.mode, expected_mode)
