def test_draft_course_staff(self): update_course_visibility(1, True, False) response = self.get_view(self.course_download_url_valid, self.staff_user) self.assertEqual(response.status_code, 200) self.assertEqual(response['content-type'], self.STR_EXPECTED_CONTENT_TYPE) update_course_visibility(1, False, False)
def test_no_access_for_draft_course(self): url = ('%s?course=' + self.valid_course) \ % reverse(self.STR_URL_REDIRECT) update_course_visibility(1, False, True) response = self.client.get(url) self.assertRaises(Http404) self.assertTemplateUsed(response, self.STR_LAUNCHER_TEMPLATE) self.assertEqual(200, response.status_code) update_course_visibility(1, False, False)
def test_archived_course_admin(self): tracker_count_start = Tracker.objects.all().count() update_course_visibility(1, False, True) resource_url = get_api_url('v2', 'course', 1) + self.STR_DOWNLOAD response = self.api_client.get( resource_url, format='json', data=self.admin_auth) self.assertEqual(response.status_code, 404) tracker_count_end = Tracker.objects.all().count() self.assertEqual(tracker_count_start, tracker_count_end)
def test_draft_course_staff(self): tracker_count_start = Tracker.objects.all().count() update_course_visibility(1, True, False) resource_url = get_api_url('v2', 'course', 1) + self.STR_DOWNLOAD response = self.api_client.get( resource_url, format='json', data=self.staff_auth) self.assertHttpOK(response) self.assertEqual(response['content-type'], self.STR_ZIP_EXPECTED_CONTENT_TYPE) update_course_visibility(1, False, False) tracker_count_end = Tracker.objects.all().count() self.assertEqual(tracker_count_start+1, tracker_count_end)
def test_archived_course_admin(self): update_course_visibility(1, False, True) response = self.get_view(self.course_download_url_valid, self.admin_user) self.assertEqual(response.status_code, 404) update_course_visibility(1, False, False)
def test_draft_course_normal(self): update_course_visibility(1, True, False) response = self.get_view(self.course_download_url_valid, self.normal_user) self.assertEqual(response.status_code, 404) update_course_visibility(1, False, False)
def test_archived_shortname(self): update_course_visibility(1, 0, 1) url = get_api_url('v2', 'coursestructure') + "anc1-all/" response = self.client.get(url) self.assertHttpNotFound(response) update_course_visibility(1, 0, 0)
def test_draft_id(self): update_course_visibility(1, 1, 0) url = get_api_url('v2', 'coursestructure') + "1/" response = self.client.get(url) self.assertHttpNotFound(response) update_course_visibility(1, 0, 0)