'Test user can invalidate a generated certificate.'

def test_invalidate_certificate(self):

    response = self.client.post(self.url, data=json.dumps(self.certificate_invalidation_data), content_type='application/json')
    self.assertEqual(response.status_code, 200)
    result = json.loads(response.content)
    self.assertEqual(result['user'], self.enrolled_user_1.username)
    self.assertEqual(result['invalidated_by'], self.global_staff.username)
    self.assertEqual(result['notes'], self.notes)
    try:
        CertificateInvalidation.objects.get(generated_certificate=self.generated_certificate, invalidated_by=self.global_staff, notes=self.notes, active=True)
    except ObjectDoesNotExist:
        self.fail('The    certificate    is    not    invalidated.')
    generated_certificate = GeneratedCertificate.eligible_certificates.get(user=self.enrolled_user_1, course_id=self.course.id)
    self.assertFalse(generated_certificate.is_valid())
