@@ -622,6 +622,9 @@ class BulkImportObjectsViewTestCase(ModelViewTestCase):
622
622
623
623
csv_data = ()
624
624
625
+ def get_scenarios (self ):
626
+ return self .csv_data .keys () if isinstance (self .csv_data , dict ) else ['default' ]
627
+
625
628
def _get_csv_data (self , scenario_name = 'default' ):
626
629
"""
627
630
Get CSV data for testing. Supports both tuple/list and dictionary formats.
@@ -657,8 +660,6 @@ def test_bulk_import_objects_without_permission(self):
657
660
658
661
@override_settings (EXEMPT_VIEW_PERMISSIONS = ['*' ], EXEMPT_EXCLUDE_MODELS = [])
659
662
def test_bulk_import_objects_with_permission (self , post_import_callback = None ):
660
- scenarios = self .csv_data .keys () if isinstance (self .csv_data , dict ) else ['default' ]
661
-
662
663
# Assign model-level permission once for all scenarios
663
664
obj_perm = ObjectPermission (name = 'Test permission' , actions = ['add' ])
664
665
obj_perm .save ()
@@ -669,7 +670,7 @@ def test_bulk_import_objects_with_permission(self, post_import_callback=None):
669
670
self .assertHttpStatus (self .client .get (self ._get_url ('bulk_import' )), 200 )
670
671
671
672
# Test each scenario
672
- for scenario_name in scenarios :
673
+ for scenario_name in self . get_scenarios () :
673
674
with self .cleanupSubTest (scenario = scenario_name ):
674
675
self ._test_bulk_import_with_permission_scenario (scenario_name )
675
676
@@ -757,8 +758,6 @@ def test_bulk_update_objects_with_permission(self):
757
758
758
759
@override_settings (EXEMPT_VIEW_PERMISSIONS = ['*' ], EXEMPT_EXCLUDE_MODELS = [])
759
760
def test_bulk_import_objects_with_constrained_permission (self , post_import_callback = None ):
760
- scenarios = self .csv_data .keys () if isinstance (self .csv_data , dict ) else ['default' ]
761
-
762
761
# Assign constrained permission (deny all initially)
763
762
obj_perm = ObjectPermission (
764
763
name = 'Test permission' ,
@@ -770,7 +769,7 @@ def test_bulk_import_objects_with_constrained_permission(self, post_import_callb
770
769
obj_perm .object_types .add (ObjectType .objects .get_for_model (self .model ))
771
770
772
771
# Test each scenario with constrained permissions
773
- for scenario_name in scenarios :
772
+ for scenario_name in self . get_scenarios () :
774
773
with self .cleanupSubTest (scenario = scenario_name ):
775
774
self ._test_bulk_import_constrained_scenario (scenario_name , obj_perm )
776
775
0 commit comments