3737from lxml import etree
3838from path import Path as path
3939from xmodule .contentstore .content import StaticContent
40- from xmodule . course_block import (
40+ from openedx . core . djangoapps . video_config . utils import (
4141 COURSE_VIDEO_SHARING_ALL_VIDEOS ,
4242 COURSE_VIDEO_SHARING_NONE ,
4343 COURSE_VIDEO_SHARING_PER_VIDEO
5757from common .djangoapps .xblock_django .constants import ATTR_KEY_REQUEST_COUNTRY_CODE
5858from lms .djangoapps .courseware .tests .helpers import get_context_dict_from_string
5959from openedx .core .djangoapps .video_config .toggles import PUBLIC_VIDEO_SHARE
60+ from openedx .core .djangoapps .video_config .utils import VideoSharingUtils
6061from openedx .core .djangoapps .video_pipeline .config .waffle import DEPRECATE_YOUTUBE
6162from openedx .core .djangoapps .waffle_utils .models import WaffleFlagCourseOverrideModel
6263from openedx .core .djangolib .testing .utils import CacheIsolationTestCase
@@ -261,14 +262,14 @@ def test_is_public_sharing_enabled(self, feature_enabled):
261262 """Test public video url."""
262263 assert self .block .public_access is True
263264 with self .mock_feature_toggle (enabled = feature_enabled ):
264- assert self . block . is_public_sharing_enabled () == feature_enabled
265+ assert VideoSharingUtils . is_public_sharing_enabled (self . block ) == feature_enabled
265266
266267 def test_is_public_sharing_enabled__not_public (self ):
267268 self .block .public_access = False
268269 with self .mock_feature_toggle ():
269- assert not self . block . is_public_sharing_enabled ()
270+ assert not VideoSharingUtils . is_public_sharing_enabled (self . block )
270271
271- @patch ('xmodule.video_block.video_block.VideoBlock .get_course_video_sharing_override' )
272+ @patch ('openedx.core.djangoapps.video_config.utils.VideoSharingUtils .get_course_video_sharing_override' )
272273 def test_is_public_sharing_enabled_by_course_override (self , mock_course_sharing_override ):
273274
274275 # Given a course overrides all videos to be shared
@@ -277,47 +278,47 @@ def test_is_public_sharing_enabled_by_course_override(self, mock_course_sharing_
277278
278279 # When I try to determine if public sharing is enabled
279280 with self .mock_feature_toggle ():
280- is_public_sharing_enabled = self . block . is_public_sharing_enabled ()
281+ is_public_sharing_enabled = VideoSharingUtils . is_public_sharing_enabled (self . block )
281282
282283 # Then I will get that course value
283284 self .assertTrue (is_public_sharing_enabled )
284285
285- @patch ('xmodule.video_block.video_block.VideoBlock .get_course_video_sharing_override' )
286+ @patch ('openedx.core.djangoapps.video_config.utils.VideoSharingUtils .get_course_video_sharing_override' )
286287 def test_is_public_sharing_disabled_by_course_override (self , mock_course_sharing_override ):
287288 # Given a course overrides no videos to be shared
288289 mock_course_sharing_override .return_value = COURSE_VIDEO_SHARING_NONE
289290 self .block .public_access = 'some-arbitrary-value'
290291
291292 # When I try to determine if public sharing is enabled
292293 with self .mock_feature_toggle ():
293- is_public_sharing_enabled = self . block . is_public_sharing_enabled ()
294+ is_public_sharing_enabled = VideoSharingUtils . is_public_sharing_enabled (self . block )
294295
295296 # Then I will get that course value
296297 self .assertFalse (is_public_sharing_enabled )
297298
298299 @ddt .data (COURSE_VIDEO_SHARING_PER_VIDEO , None )
299- @patch ('xmodule.video_block.video_block.VideoBlock .get_course_video_sharing_override' )
300+ @patch ('openedx.core.djangoapps.video_config.utils.VideoSharingUtils .get_course_video_sharing_override' )
300301 def test_is_public_sharing_enabled_per_video (self , mock_override_value , mock_course_sharing_override ):
301302 # Given a course does not override per-video settings
302303 mock_course_sharing_override .return_value = mock_override_value
303304 self .block .public_access = 'some-arbitrary-value'
304305
305306 # When I try to determine if public sharing is enabled
306307 with self .mock_feature_toggle ():
307- is_public_sharing_enabled = self . block . is_public_sharing_enabled ()
308+ is_public_sharing_enabled = VideoSharingUtils . is_public_sharing_enabled (self . block )
308309
309310 # I will get the per-video value
310311 self .assertEqual (self .block .public_access , is_public_sharing_enabled )
311312
312- @patch ('xmodule.video_block.video_block .get_course_by_id' )
313+ @patch ('openedx.core.lib.courses .get_course_by_id' )
313314 def test_is_public_sharing_course_not_found (self , mock_get_course ):
314315 # Given a course does not override per-video settings
315316 mock_get_course .side_effect = Http404 ()
316317 self .block .public_access = 'some-arbitrary-value'
317318
318319 # When I try to determine if public sharing is enabled
319320 with self .mock_feature_toggle ():
320- is_public_sharing_enabled = self . block . is_public_sharing_enabled ()
321+ is_public_sharing_enabled = VideoSharingUtils . is_public_sharing_enabled (self . block )
321322
322323 # I will fall-back to per-video values
323324 self .assertEqual (self .block .public_access , is_public_sharing_enabled )
@@ -326,7 +327,7 @@ def test_is_public_sharing_course_not_found(self, mock_get_course):
326327 def test_context (self , is_public_sharing_enabled ):
327328 with self .mock_feature_toggle ():
328329 with patch .object (
329- self . block ,
330+ VideoSharingUtils ,
330331 'is_public_sharing_enabled' ,
331332 return_value = is_public_sharing_enabled
332333 ):
0 commit comments