2222 ScopeIds , Sentinel , UNIQUE_ID , scope_key , Date , Timedelta , RelativeTime , ScoreField , ListScoreField
2323)
2424from xblock .scorable import Score
25- from xblock .test .tools import TestRuntime
25+ from xblock .test .tools import TestRuntime , make_scope_ids_for_testing
2626
2727
2828class FieldTest (unittest .TestCase ):
@@ -41,7 +41,7 @@ class TestBlock(XBlock):
4141 field_x = self .FIELD_TO_TEST (enforce_type = enforce_type )
4242
4343 runtime = TestRuntime (services = {'field-data' : DictFieldData ({})})
44- return TestBlock (runtime , scope_ids = Mock ( spec = ScopeIds ))
44+ return TestBlock (runtime , scope_ids = make_scope_ids_for_testing ( ))
4545
4646 def set_and_get_field (self , arg , enforce_type ):
4747 """
@@ -717,10 +717,11 @@ class TestBlock(XBlock):
717717 pref_lst = List (scope = Scope .preferences , name = '' )
718718 user_info_lst = List (scope = Scope .user_info , name = '' )
719719
720- sids = ScopeIds (user_id = "_bob" ,
721- block_type = "b.12#ob" ,
722- def_id = ".." ,
723- usage_id = ".." )
720+ sids = make_scope_ids_for_testing (
721+ user_id = "_bob" ,
722+ block_type = "b.12#ob" ,
723+ block_id = ".." ,
724+ )
724725
725726 field_data = DictFieldData ({})
726727
@@ -763,10 +764,11 @@ class TestBlock(XBlock):
763764 field_a = String (default = UNIQUE_ID , scope = Scope .settings )
764765 field_b = String (default = UNIQUE_ID , scope = Scope .user_state )
765766
766- sids = ScopeIds (user_id = "bob" ,
767- block_type = "bobs-type" ,
768- def_id = "definition-id" ,
769- usage_id = "usage-id" )
767+ sids = make_scope_ids_for_testing (
768+ user_id = "bob" ,
769+ block_type = "bobs-type" ,
770+ block_id = "usage-id" ,
771+ )
770772
771773 runtime = TestRuntime (services = {'field-data' : DictFieldData ({})})
772774 block = TestBlock (runtime , DictFieldData ({}), sids )
@@ -828,7 +830,7 @@ class FieldTester(XBlock):
828830 not_timezone_aware = dt .datetime (2015 , 1 , 1 )
829831 timezone_aware = dt .datetime (2015 , 1 , 1 , tzinfo = pytz .UTC )
830832 runtime = TestRuntime (services = {'field-data' : DictFieldData ({})})
831- field_tester = FieldTester (runtime , scope_ids = Mock ( spec = ScopeIds ))
833+ field_tester = FieldTester (runtime , scope_ids = make_scope_ids_for_testing ( ))
832834 field_tester .incomparable = not_timezone_aware
833835 field_tester .incomparable = timezone_aware
834836 assert field_tester .incomparable == timezone_aware
@@ -853,7 +855,7 @@ class FieldTester(XBlock):
853855
854856 original_json = "YYY"
855857 runtime = TestRuntime (services = {'field-data' : DictFieldData ({'how_many' : original_json })})
856- field_tester = FieldTester (runtime , scope_ids = Mock ( spec = ScopeIds ))
858+ field_tester = FieldTester (runtime , scope_ids = make_scope_ids_for_testing ( ))
857859
858860 # Test that the native value isn't equal to the original json we specified.
859861 assert field_tester .how_many != original_json
@@ -879,7 +881,7 @@ class FieldTester(XBlock):
879881 dict_field = Dict (scope = Scope .settings )
880882
881883 runtime = TestRuntime (services = {'field-data' : DictFieldData ({})})
882- field_tester = FieldTester (runtime , scope_ids = Mock ( spec = ScopeIds ))
884+ field_tester = FieldTester (runtime , scope_ids = make_scope_ids_for_testing ( ))
883885
884886 # precondition checks
885887 assert len (field_tester ._dirty_fields ) == 0
0 commit comments