'Test patch 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_patch_user_on_active_state(self, auth_attr, user_is_active):

    self.app_user.is_active = user_is_active
    self.app_user.save()
    chapters = self.master_course_chapters[0:1]
    data = {'course_modules': (chapters * 3)}
    resp = self.client.patch(self.detail_url, data, format='json', 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)
        ccx_from_db = CustomCourseForEdX.objects.get(id=self.ccx.id)
        self.assertItemsEqual(ccx_from_db.structure, chapters)
