Exemple #1
0
 def test_main_with_missing_user_id(self):
     del self.request.session['LTI_LAUNCH']['user_id']
     response = views.get_canvas_modules(self.request)
     self.assertEqual(
         response.status_code, 400,
         'Expected Bad Request status code when LTI_LAUNCH[user_id] not in session'
     )
Exemple #2
0
 def test_main_with_missing_course_id(self):
     del self.request.GET['course_id']
     response = views.get_canvas_modules(self.request)
     self.assertEqual(
         response.status_code, 400,
         'Expected Bad Request status code when LTI_LAUNCH not in session'
     )
Exemple #3
0
 def test_main_with_missing_auth(self):
     with patch('edx2canvas.models.CanvasApiAuthorization.objects.get') as get_mock:
         get_mock.side_effect = models.CanvasApiAuthorization.DoesNotExist()
         response = views.get_canvas_modules(self.request)
     self.assertEqual(
         response.status_code, 403,
         'Expected Forbidden status code if no API key exists. Got: {}'.format(response.status_code)
     )
Exemple #4
0
 def test_main_with_missing_auth(self):
     with patch('edx2canvas.models.CanvasApiAuthorization.objects.get'
                ) as get_mock:
         get_mock.side_effect = models.CanvasApiAuthorization.DoesNotExist()
         response = views.get_canvas_modules(self.request)
     self.assertEqual(
         response.status_code, 403,
         'Expected Forbidden status code if no API key exists. Got: {}'.
         format(response.status_code))
Exemple #5
0
 def test_get_modules(self):
     response = views.get_canvas_modules(self.request)
     self.assertEqual(json.loads(response.content), {
         'id': self.canvas_course_id,
         'modules': self.module_list
     })
Exemple #6
0
 def test_get_modules(self):
     response = views.get_canvas_modules(self.request)
     self.assertEqual(
         json.loads(response.content),
         {'id': self.canvas_course_id, 'modules': self.module_list}
     )