'Test for deleting a ccx course on user\'s active state.'

@ddt.data(('auth', True), ('auth', False), ('auth_header_oauth2_provider', True), ('auth_header_oauth2_provider', False))
@ddt.unpack
def test_delete_detail_on_active_state(self, auth_attr, user_is_active):

    self.app_user.is_active = user_is_active
    self.app_user.save()
    self.assertGreater(CcxFieldOverride.objects.filter(ccx=self.ccx).count(), 0)
    self.assertGreater(CourseEnrollment.objects.filter(course_id=self.ccx_key).count(), 0)
    resp = self.client.delete(self.detail_url, {}, HTTP_AUTHORIZATION=getattr(self, auth_attr))
    if (not user_is_active):
        self.assertEqual(resp.status_code, status.HTTP_403_FORBIDDEN)
    else:
        self.assertEqual(resp.status_code, status.HTTP_204_NO_CONTENT)
        self.assertIsNone(resp.data)
        with self.assertRaises(CustomCourseForEdX.DoesNotExist):
            CustomCourseForEdX.objects.get(id=self.ccx.id)
        self.assertEqual(CcxFieldOverride.objects.filter(ccx=self.ccx).count(), 0)
        self.assertEqual(CourseEnrollment.objects.filter(course_id=self.ccx_key).count(), 0)
