Skip to content

Commit ab00245

Browse files
committed
Make sure resources are provisioned with a valid minimal conf to get picked up
by the traversal in map updates. Add basic load_X_map tests.
1 parent 977af0a commit ab00245

File tree

1 file changed

+41
-5
lines changed

1 file changed

+41
-5
lines changed

tests/test_mig_shared_vgridaccess.py

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@
3636
USERID, VGRIDS, check_vgrid_access, check_vgrids_modified, \
3737
force_update_resource_map, force_update_user_map, force_update_vgrid_map, \
3838
get_re_provider_map, get_resource_map, get_user_map, get_vgrid_map, \
39-
load_resource_map, mark_vgrid_modified, refresh_resource_map, \
40-
refresh_user_map, refresh_vgrid_map, res_vgrid_access, \
41-
reset_vgrids_modified, resources_using_re, unmap_vgrid, user_vgrid_access, \
42-
vgrid_inherit_map
39+
load_resource_map, load_user_map, load_vgrid_map, mark_vgrid_modified, \
40+
refresh_resource_map, refresh_user_map, refresh_vgrid_map, \
41+
res_vgrid_access, reset_vgrids_modified, resources_using_re, unmap_vgrid, \
42+
user_vgrid_access, vgrid_inherit_map
4343
from tests.support import MigTestCase, ensure_dirs_exist, testmain
4444

4545

@@ -107,7 +107,8 @@ def _create_resource(self, res_name, owners, config=None):
107107
saved = pickle(owners, res_owners_path, self.logger)
108108
self.assertTrue(saved)
109109
if config is None:
110-
config = {}
110+
# Make sure conf has one valid field
111+
config = {'HOSTURL': res_name}
111112
saved = pickle(config, res_config_path, self.logger)
112113
self.assertTrue(saved)
113114

@@ -200,6 +201,41 @@ def test_get_vgrid_map(self):
200201
self.assertTrue(vgrid_map)
201202
self.assertIn(self.test_vgrid, vgrid_map.get(VGRIDS, []))
202203

204+
def test_load_user_map(self):
205+
"""Basic test for direct user map loading"""
206+
# Get empty map initially
207+
user_map, map_stamp = load_user_map(self.configuration)
208+
self.assertEqual(user_map, {})
209+
# Add test user
210+
self._provision_test_user(self, self.TEST_USER_DN)
211+
force_update_user_map(self.configuration)
212+
# Verify updated map contains user
213+
updated_map, updated_stamp = load_user_map(self.configuration)
214+
self.assertIn(self.TEST_USER_DN, updated_map)
215+
216+
def test_load_resource_map(self):
217+
"""Basic test for direct resource map loading"""
218+
# Get empty map initially
219+
res_map, map_stamp = load_resource_map(self.configuration)
220+
self.assertEqual(res_map, {})
221+
# Add test resource
222+
self._create_resource(self.TEST_RESOURCE_ID, [self.TEST_OWNER_DN])
223+
force_update_resource_map(self.configuration)
224+
# Verify updated map contains resource after refresh
225+
res_map, map_stamp = load_resource_map(self.configuration)
226+
self.assertIn(self.TEST_RESOURCE_ID, res_map)
227+
228+
def test_load_vgrid_map(self):
229+
"""Basic test for direct vgrid map loading"""
230+
# Get map with at least 'Generic' vgrid
231+
vgrid_map, map_stamp = load_vgrid_map(self.configuration)
232+
self.assertIn('Generic', vgrid_map.get(VGRIDS, {}))
233+
self._create_vgrid(self.test_vgrid, [self.TEST_OWNER_DN])
234+
force_update_vgrid_map(self.configuration)
235+
# Verify updated map contains vgrid after refresh
236+
vgrid_map, map_stamp = load_vgrid_map(self.configuration)
237+
self.assertIn(self.test_vgrid, vgrid_map.get(VGRIDS, {}))
238+
203239
def test_check_vgrids_modified(self):
204240
"""Minimal test for vgrid modified tracking"""
205241
# Initially ALL marked modified until cache init

0 commit comments

Comments
 (0)