'Configure the certificate status by mocking the certificates API.'

@contextlib.contextmanager
def _certificate_status(self, description, status):

    patched = 'lms.djangoapps.instructor.views.instructor_dashboard.certs_api.example_certificates_status'
    with mock.patch(patched) as certs_api_status:
        cert_status = [{'description': description, 'status': status}]
        if (status == 'error'):
            cert_status[0]['error_reason'] = self.ERROR_REASON
        if (status == 'success'):
            cert_status[0]['download_url'] = self.DOWNLOAD_URL
        certs_api_status.return_value = cert_status
        (yield)
