@@ -82,31 +82,40 @@ def _provide_configuration(self):
8282 return 'testconfig'
8383
8484 def _create_vgrid (self , vgrid_name , owners = None , members = None ,
85- resources = None , settings = None ):
85+ resources = None , settings = None , triggers = None ):
8686 """Helper to create valid skeleton vgrid for testing"""
8787 vgrid_path = os .path .join (self .configuration .vgrid_home , vgrid_name )
8888 ensure_dirs_exist (vgrid_path )
89+ # Save vgrid owners, members, resources, settings and triggers
8990 if owners is None :
9091 owners = []
91- # Add vgrid owners
92- status , msg = vgrid_set_entities ( self . configuration , vgrid_name ,
93- 'owners' , owners , allow_empty = True )
94- self . assertTrue ( status , msg )
95- if members is not None :
96- status , msg = vgrid_set_entities (self .configuration , vgrid_name ,
92+ success_and_msg = vgrid_set_entities ( self . configuration , vgrid_name ,
93+ 'owners' , owners , allow_empty = True )
94+ self . assertEqual ( success_and_msg , ( True , "" ) )
95+ if members is None :
96+ members = []
97+ success_and_msg = vgrid_set_entities (self .configuration , vgrid_name ,
9798 'members' , members ,
98- allow_empty = False )
99- self .assertTrue (status , msg )
100- if resources is not None :
101- status , msg = vgrid_set_entities (self .configuration , vgrid_name ,
99+ allow_empty = True )
100+ self .assertEqual (success_and_msg , (True , "" ))
101+ if resources is None :
102+ resources = []
103+ success_and_msg = vgrid_set_entities (self .configuration , vgrid_name ,
102104 'resources' , resources ,
103- allow_empty = False )
104- self .assertTrue (status , msg )
105- if settings is not None :
106- status , msg = vgrid_set_entities (self .configuration , vgrid_name ,
105+ allow_empty = True )
106+ self .assertEqual (success_and_msg , (True , "" ))
107+ if settings is None :
108+ settings = [('vgrid_name' , vgrid_name )]
109+ success_and_msg = vgrid_set_entities (self .configuration , vgrid_name ,
107110 'settings' , settings ,
108- allow_empty = False )
109- self .assertTrue (status , msg )
111+ allow_empty = True )
112+ self .assertEqual (success_and_msg , (True , "" ))
113+ if triggers is None :
114+ triggers = []
115+ success_and_msg = vgrid_set_entities (self .configuration , vgrid_name ,
116+ 'triggers' , triggers ,
117+ allow_empty = True )
118+ self .assertEqual (success_and_msg , (True , "" ))
110119
111120 def _create_resource (self , res_name , owners , config = None ):
112121 """Helper to create valid skeleton resource for testing"""
@@ -147,6 +156,8 @@ def before_each(self):
147156 ]
148157 for state_dir in used_state_dirs :
149158 ensure_dirs_exist (state_dir )
159+ # Make sure no stale data is left
160+ self .assertEqual (os .listdir (state_dir ), [])
150161
151162 # Drop all caches and state between tests
152163 self ._reset_caches ()
@@ -638,9 +649,9 @@ def test_resource_revoked_access(self):
638649 self .assertIn (self .TEST_RESOURCE_ID , initial_map )
639650
640651 # Remove resource assignment from vgrid
641- status , msg = vgrid_set_entities (self .configuration , self .TEST_VGRID_NAME ,
642- 'resources' , [], allow_empty = True )
643- self .assertTrue ( status , msg )
652+ success_and_msg = vgrid_set_entities (self .configuration , self .TEST_VGRID_NAME ,
653+ 'resources' , [], allow_empty = True )
654+ self .assertEqual ( success_and_msg , ( True , '' ) )
644655
645656 updated_vgrid_map = force_update_vgrid_map (self .configuration )
646657 # Check vgrid map no longer contains resource entry
0 commit comments