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 . sharing 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 import sharing
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
@@ -260,14 +261,14 @@ def test_is_public_sharing_enabled(self, feature_enabled):
260261 """Test public video url."""
261262 assert self .block .public_access is True
262263 with self .mock_feature_toggle (enabled = feature_enabled ):
263- assert self .block .is_public_sharing_enabled ( ) == feature_enabled
264+ assert sharing . is_public_sharing_enabled ( self .block .location , self . block . public_access ) == feature_enabled
264265
265266 def test_is_public_sharing_enabled__not_public (self ):
266267 self .block .public_access = False
267268 with self .mock_feature_toggle ():
268- assert not self .block .is_public_sharing_enabled ( )
269+ assert not sharing . is_public_sharing_enabled ( self .block .location , self . block . public_access )
269270
270- @patch ('xmodule.video_block.video_block.VideoBlock .get_course_video_sharing_override' )
271+ @patch ('openedx.core.djangoapps.video_config.sharing .get_course_video_sharing_override' )
271272 def test_is_public_sharing_enabled_by_course_override (self , mock_course_sharing_override ):
272273
273274 # Given a course overrides all videos to be shared
@@ -276,47 +277,47 @@ def test_is_public_sharing_enabled_by_course_override(self, mock_course_sharing_
276277
277278 # When I try to determine if public sharing is enabled
278279 with self .mock_feature_toggle ():
279- is_public_sharing_enabled = self .block .is_public_sharing_enabled ( )
280+ is_public_sharing_enabled = sharing . is_public_sharing_enabled ( self .block .location , self . block . public_access )
280281
281282 # Then I will get that course value
282283 self .assertTrue (is_public_sharing_enabled )
283284
284- @patch ('xmodule.video_block.video_block.VideoBlock .get_course_video_sharing_override' )
285+ @patch ('openedx.core.djangoapps.video_config.sharing .get_course_video_sharing_override' )
285286 def test_is_public_sharing_disabled_by_course_override (self , mock_course_sharing_override ):
286287 # Given a course overrides no videos to be shared
287288 mock_course_sharing_override .return_value = COURSE_VIDEO_SHARING_NONE
288289 self .block .public_access = 'some-arbitrary-value'
289290
290291 # When I try to determine if public sharing is enabled
291292 with self .mock_feature_toggle ():
292- is_public_sharing_enabled = self .block .is_public_sharing_enabled ( )
293+ is_public_sharing_enabled = sharing . is_public_sharing_enabled ( self .block .location , self . block . public_access )
293294
294295 # Then I will get that course value
295296 self .assertFalse (is_public_sharing_enabled )
296297
297298 @ddt .data (COURSE_VIDEO_SHARING_PER_VIDEO , None )
298- @patch ('xmodule.video_block.video_block.VideoBlock .get_course_video_sharing_override' )
299+ @patch ('openedx.core.djangoapps.video_config.sharing .get_course_video_sharing_override' )
299300 def test_is_public_sharing_enabled_per_video (self , mock_override_value , mock_course_sharing_override ):
300301 # Given a course does not override per-video settings
301302 mock_course_sharing_override .return_value = mock_override_value
302303 self .block .public_access = 'some-arbitrary-value'
303304
304305 # When I try to determine if public sharing is enabled
305306 with self .mock_feature_toggle ():
306- is_public_sharing_enabled = self .block .is_public_sharing_enabled ( )
307+ is_public_sharing_enabled = sharing . is_public_sharing_enabled ( self .block .location , self . block . public_access )
307308
308309 # I will get the per-video value
309310 self .assertEqual (self .block .public_access , is_public_sharing_enabled )
310311
311- @patch ('xmodule.video_block.video_block .get_course_by_id' )
312+ @patch ('openedx.core.lib.courses .get_course_by_id' )
312313 def test_is_public_sharing_course_not_found (self , mock_get_course ):
313314 # Given a course does not override per-video settings
314315 mock_get_course .side_effect = Http404 ()
315316 self .block .public_access = 'some-arbitrary-value'
316317
317318 # When I try to determine if public sharing is enabled
318319 with self .mock_feature_toggle ():
319- is_public_sharing_enabled = self .block .is_public_sharing_enabled ( )
320+ is_public_sharing_enabled = sharing . is_public_sharing_enabled ( self .block .location , self . block . public_access )
320321
321322 # I will fall-back to per-video values
322323 self .assertEqual (self .block .public_access , is_public_sharing_enabled )
@@ -325,7 +326,7 @@ def test_is_public_sharing_course_not_found(self, mock_get_course):
325326 def test_context (self , is_public_sharing_enabled ):
326327 with self .mock_feature_toggle ():
327328 with patch .object (
328- self . block ,
329+ sharing ,
329330 'is_public_sharing_enabled' ,
330331 return_value = is_public_sharing_enabled
331332 ):
0 commit comments