'Test error message if certificate invalidation for the student is already present.'

def test_duplicate_certificate_invalidation_error(self):

    CertificateInvalidationFactory.create(generated_certificate=self.generated_certificate, invalidated_by=self.global_staff)
    self.generated_certificate.invalidate()
    response = self.client.post(self.url, data=json.dumps(self.certificate_invalidation_data), content_type='application/json')
    self.assertEqual(response.status_code, 400)
    res_json = json.loads(response.content)
    self.assertEqual(res_json['message'], u'Certificate    of    {user}    has    already    been    invalidated.    Please    check    your    spelling    and    retry.'.format(user=self.enrolled_user_1.username))
