def test_post_course_certificate(self): """ Ensure the correct API call gets made """ test_client = EdxRestApiClient('http://test-server', jwt='test-token') httpretty.register_uri( httpretty.POST, 'http://test-server/credentials/', ) visible_date = datetime.now() tasks.post_course_certificate(test_client, self.student.username, self.certificate, visible_date) expected_body = { 'username': self.student.username, 'status': 'awarded', 'credential': { 'course_run_key': str(self.certificate.course_id), 'mode': self.certificate.mode, 'type': tasks.COURSE_CERTIFICATE, }, 'attributes': [{ 'name': 'visible_date', 'value': visible_date.strftime( '%Y-%m-%dT%H:%M:%SZ') # text representation of date }] } self.assertEqual(json.loads(httpretty.last_request().body), expected_body)
def test_post_course_certificate(self): """ Ensure the correct API call gets made """ test_client = EdxRestApiClient('http://test-server', jwt='test-token') httpretty.register_uri( httpretty.POST, 'http://test-server/credentials/', ) visible_date = datetime.now() tasks.post_course_certificate(test_client, self.student.username, self.certificate, visible_date) expected_body = { 'username': self.student.username, 'status': 'awarded', 'credential': { 'course_run_key': str(self.certificate.course_id), 'mode': self.certificate.mode, 'type': tasks.COURSE_CERTIFICATE, }, 'attributes': [{ 'name': 'visible_date', 'value': visible_date.strftime('%Y-%m-%dT%H:%M:%SZ') # text representation of date }] } self.assertEqual(json.loads(httpretty.last_request().body), expected_body)