3030import time
3131import unittest
3232
33+ # IMPORTANT: reset of cross-module globals requires module-level import
34+ import mig .shared .vgridaccess as vgridaccess
3335from mig .shared .fileio import pickle , read_file
3436from mig .shared .vgrid import vgrid_list , vgrid_set_entities , vgrid_settings
3537from mig .shared .vgridaccess import CONF , MEMBERS , OWNERS , RESOURCES , SETTINGS , \
3638 USERID , USERS , VGRIDS , check_resources_modified , check_vgrid_access , \
3739 check_vgrids_modified , fill_placeholder_cache , force_update_resource_map , \
3840 force_update_user_map , force_update_vgrid_map , get_re_provider_map , \
3941 get_resource_map , get_user_map , get_vgrid_map , get_vgrid_map_vgrids , \
40- is_vgrid_parent_placeholder , last_load , last_map , last_refresh , \
41- load_resource_map , load_user_map , load_vgrid_map , mark_vgrid_modified , \
42- refresh_resource_map , refresh_user_map , refresh_vgrid_map , \
43- res_vgrid_access , reset_resources_modified , reset_vgrids_modified , \
44- resources_using_re , unmap_inheritance , unmap_resource , unmap_vgrid , \
45- user_allowed_res_confs , user_allowed_res_exes , user_allowed_res_stores , \
46- user_allowed_res_units , user_allowed_user_confs , user_owned_res_exes , \
47- user_owned_res_stores , user_vgrid_access , user_visible_res_confs , \
48- user_visible_res_exes , user_visible_res_stores , user_visible_user_confs , \
49- vgrid_inherit_map
42+ is_vgrid_parent_placeholder , load_resource_map , load_user_map , \
43+ load_vgrid_map , mark_vgrid_modified , refresh_resource_map , \
44+ refresh_user_map , refresh_vgrid_map , res_vgrid_access , \
45+ reset_resources_modified , reset_vgrids_modified , resources_using_re , \
46+ unmap_inheritance , unmap_resource , unmap_vgrid , user_allowed_res_confs , \
47+ user_allowed_res_exes , user_allowed_res_stores , user_allowed_res_units , \
48+ user_allowed_user_confs , user_owned_res_exes , user_owned_res_stores , \
49+ user_vgrid_access , user_visible_res_confs , user_visible_res_exes , \
50+ user_visible_res_stores , user_visible_user_confs , vgrid_inherit_map
5051from tests .support import MigTestCase , ensure_dirs_exist , testmain
5152
5253
@@ -130,9 +131,9 @@ def _create_resource(self, res_name, owners, config=None):
130131 def _reset_caches (self ):
131132 """Assure all vgrid maps and stamps are wiped for next test"""
132133 for field in (USERS , RESOURCES , VGRIDS ):
133- last_refresh [field ] = 0
134- last_load [field ] = 0
135- last_map [field ].clear ()
134+ vgridaccess . last_refresh [field ] = 0
135+ vgridaccess . last_load [field ] = 0
136+ vgridaccess . last_map [field ].clear ()
136137
137138 def before_each (self ):
138139 """Create clean test environment for vgridaccess tests"""
@@ -152,9 +153,9 @@ def before_each(self):
152153
153154 # Make sure we start with a clean slate for each test
154155 for field in (USERS , RESOURCES , VGRIDS ):
155- self .assertTrue (last_refresh [field ] == 0 )
156- self .assertTrue (last_load [field ] == 0 )
157- self .assertEqual (last_map [field ], {})
156+ self .assertTrue (vgridaccess . last_refresh [field ] == 0 )
157+ self .assertTrue (vgridaccess . last_load [field ] == 0 )
158+ self .assertEqual (vgridaccess . last_map [field ], {})
158159
159160 # IMPORTANT: don't use refresh_X here as it does not reset last_X cache
160161 # Start with minimal maps and corresponding cache - only default vgrid
@@ -177,11 +178,11 @@ def before_each(self):
177178
178179 # Make sure accounting and caching entries are consistent and complete
179180 for field in (USERS , RESOURCES , VGRIDS ):
180- self .assertTrue (last_refresh [field ] > 0 )
181- self .assertTrue (last_load [field ] > 0 )
182- self .assertEqual (vgrid_map , last_map [VGRIDS ])
183- self .assertEqual (res_map , last_map [RESOURCES ])
184- self .assertEqual (user_map , last_map [USERS ])
181+ self .assertTrue (vgridaccess . last_refresh [field ] > 0 )
182+ self .assertTrue (vgridaccess . last_load [field ] > 0 )
183+ self .assertEqual (vgrid_map , vgridaccess . last_map [VGRIDS ])
184+ self .assertEqual (res_map , vgridaccess . last_map [RESOURCES ])
185+ self .assertEqual (user_map , vgridaccess . last_map [USERS ])
185186
186187 def test_force_update_user_map (self ):
187188 """Simple test that user map refresh completes"""
0 commit comments