99import ddt
1010from bs4 import BeautifulSoup
1111from django .conf import settings
12- from django .core .exceptions import PermissionDenied
1312from django .http import Http404
1413from django .test import TestCase
1514from django .test .client import RequestFactory
2019from opaque_keys .edx .asides import AsideUsageKeyV2
2120from opaque_keys .edx .keys import CourseKey , UsageKey
2221from opaque_keys .edx .locator import BlockUsageLocator , CourseLocator
22+ from openedx_authz .constants .roles import COURSE_STAFF
2323from openedx_events .content_authoring .data import DuplicatedXBlockData
2424from openedx_events .content_authoring .signals import XBLOCK_DUPLICATED
2525from openedx_events .testing import OpenEdxEventsTestMixin
5555from common .djangoapps .xblock_django .user_service import DjangoXBlockUserService
5656from common .test .utils import assert_dict_contains_subset
5757from lms .djangoapps .lms_xblock .mixin import NONSENSICAL_ACCESS_RESTRICTION
58- from openedx .core .djangoapps .authz .constants import LegacyAuthoringPermission
5958from openedx .core .djangoapps .authz .tests .mixins import CourseAuthoringAuthzTestMixin
6059from openedx .core .djangoapps .content_tagging import api as tagging_api
6160from openedx .core .djangoapps .discussions .models import DiscussionsConfiguration
6261from openedx .core .djangoapps .video_config .toggles import PUBLIC_VIDEO_SHARE
63- from openedx_authz .constants .permissions import COURSES_VIEW_COURSE
64- from openedx_authz .constants .roles import COURSE_STAFF
6562from xmodule .course_block import DEFAULT_START_DATE
6663from xmodule .modulestore import ModuleStoreEnum
6764from xmodule .modulestore .django import modulestore
@@ -3529,10 +3526,10 @@ def test_authorized_user_gets_json_response(self):
35293526 Test that authorized user gets JSON response from xblock_outline_handler.
35303527 """
35313528 outline_url = reverse_usage_url ("xblock_outline_handler" , self .usage_key )
3532-
3529+
35333530 self .client .login (username = self .authorized_user .username , password = self .password )
35343531 resp = self .client .get (outline_url , HTTP_ACCEPT = "application/json" )
3535-
3532+
35363533 assert resp .status_code == 200
35373534 json_response = json .loads (resp .content .decode ("utf-8" ))
35383535 assert "id" in json_response
@@ -3544,21 +3541,21 @@ def test_unauthorized_user_gets_permission_denied(self):
35443541 Test that unauthorized user gets 403 response from xblock_outline_handler.
35453542 """
35463543 outline_url = reverse_usage_url ("xblock_outline_handler" , self .usage_key )
3547-
3544+
35483545 self .client .login (username = self .unauthorized_user .username , password = self .password )
35493546 resp = self .client .get (outline_url , HTTP_ACCEPT = "application/json" )
3550-
3547+
35513548 assert resp .status_code == 403
35523549
35533550 def test_superuser_gets_json_response (self ):
35543551 """
35553552 Test that superuser gets JSON response from xblock_outline_handler.
35563553 """
35573554 outline_url = reverse_usage_url ("xblock_outline_handler" , self .usage_key )
3558-
3555+
35593556 self .client .login (username = self .super_user .username , password = self .password )
35603557 resp = self .client .get (outline_url , HTTP_ACCEPT = "application/json" )
3561-
3558+
35623559 assert resp .status_code == 200
35633560 json_response = json .loads (resp .content .decode ("utf-8" ))
35643561 assert "id" in json_response
@@ -3570,10 +3567,10 @@ def test_staff_user_gets_json_response(self):
35703567 Test that staff user gets JSON response from xblock_outline_handler.
35713568 """
35723569 outline_url = reverse_usage_url ("xblock_outline_handler" , self .usage_key )
3573-
3570+
35743571 self .client .login (username = self .staff_user .username , password = self .password )
35753572 resp = self .client .get (outline_url , HTTP_ACCEPT = "application/json" )
3576-
3573+
35773574 assert resp .status_code == 200
35783575 json_response = json .loads (resp .content .decode ("utf-8" ))
35793576 assert "id" in json_response
@@ -3585,10 +3582,10 @@ def test_authorized_chapter_outline(self):
35853582 Test that authorized user can access chapter-level outline.
35863583 """
35873584 outline_url = reverse_usage_url ("xblock_outline_handler" , self .chapter .location )
3588-
3585+
35893586 self .client .login (username = self .authorized_user .username , password = self .password )
35903587 resp = self .client .get (outline_url , HTTP_ACCEPT = "application/json" )
3591-
3588+
35923589 assert resp .status_code == 200
35933590 json_response = json .loads (resp .content .decode ("utf-8" ))
35943591 assert json_response ["display_name" ] == "Week 1"
@@ -3603,10 +3600,10 @@ def test_unauthorized_chapter_outline(self):
36033600 Test that unauthorized user cannot access chapter-level outline.
36043601 """
36053602 outline_url = reverse_usage_url ("xblock_outline_handler" , self .chapter .location )
3606-
3603+
36073604 self .client .login (username = self .unauthorized_user .username , password = self .password )
36083605 resp = self .client .get (outline_url , HTTP_ACCEPT = "application/json" )
3609-
3606+
36103607 assert resp .status_code == 403
36113608
36123609
0 commit comments