Best Python code snippet using tempest_python
sf_volume_manager.py
Source:sf_volume_manager.py
...195 except:196 err = get_exception()197 self.module.fail_json(msg="Error deleting volume %s" % self.volume_id,198 exception=str(err))199 def update_volume(self):200 try:201 self.sfe.modify_volume(self.volume_id,202 account_id=self.account_id,203 access=self.access,204 qos=self.qos,205 total_size=self.size,206 attributes=self.attributes)207 except:208 err = get_exception()209 self.module.fail_json(msg="Error updating volume %s" % self.name,210 exception=str(err))211 def apply(self):212 changed = False213 volume_exists = False214 update_volume = False215 volume_detail = self.get_volume()216 if volume_detail:217 volume_exists = True218 if self.state == 'absent':219 # Checking for state change(s) here, and applying it later in the code allows us to support220 # check_mode221 changed = True222 elif self.state == 'present':223 if volume_detail.access is not None and self.access is not None and volume_detail.access != self.access:224 update_volume = True225 changed = True226 elif volume_detail.account_id is not None and self.account_id is not None \227 and volume_detail.account_id != self.account_id:228 update_volume = True229 changed = True230 elif volume_detail.qos is not None and self.qos is not None and volume_detail.qos != self.qos:231 update_volume = True232 changed = True233 elif volume_detail.total_size is not None and volume_detail.total_size != self.size:234 size_difference = abs(float(volume_detail.total_size - self.size))235 # Change size only if difference is bigger than 0.001236 if size_difference/self.size > 0.001:237 update_volume = True238 changed = True239 elif volume_detail.attributes is not None and self.attributes is not None and \240 volume_detail.attributes != self.attributes:241 update_volume = True242 changed = True243 else:244 if self.state == 'present':245 changed = True246 result_message = ""247 if changed:248 if self.module.check_mode:249 result_message = "Check mode, skipping changes"250 else:251 if self.state == 'present':252 if not volume_exists:253 self.create_volume()254 result_message = "Volume created"255 elif update_volume:256 self.update_volume()257 result_message = "Volume updated"258 elif self.state == 'absent':259 self.delete_volume()260 result_message = "Volume deleted"261 self.module.exit_json(changed=changed, msg=result_message)262def main():263 v = SolidFireVolume()264 v.apply()265if __name__ == '__main__':...
test_sf_volumes_update.py
Source:test_sf_volumes_update.py
...38 new_v_name = data_utils.rand_name('new-Volume')39 new_desc = 'This is the new description of volume'40 params = {self.name_field: new_v_name,41 self.descrip_field: new_desc}42 update_volume = self.client.update_volume(volume['id'], **params)43 # Assert response body for update_volume method44 self.assertNotEqual(new_v_name, volume[self.name_field])45 self.assertNotEqual(new_desc, volume[self.descrip_field])46 self.assertEqual(new_v_name, update_volume[self.name_field])47 self.assertEqual(new_desc, update_volume[self.descrip_field])48 @test.attr(type='smoke')49 @test.idempotent_id('020d3e4e-88b5-4489-917e-856cbc032139')50 def test_volume_update_with_specific_character_name(self):51 volume = self._volume_create()52 # Test volume name update specific characters53 new_v_name = data_utils.rand_name('@#$%^')54 params = {self.name_field: new_v_name}55 update_volume = self.client.update_volume(volume['id'], **params)56 # Assert response body for update_volume method57 self.assertNotEqual(new_v_name, volume[self.name_field])58 self.assertEqual(new_v_name, update_volume[self.name_field])59 @test.attr(type='smoke')60 @test.idempotent_id('e6fe35d9-c183-44b0-b8c3-35aeff89190f')61 def test_volume_update_with_none_desc(self):62 volume = self._volume_create()63 # Test volume description none64 new_desc = None65 params = {self.descrip_field: new_desc}66 update_volume = self.client.update_volume(volume['id'], **params)67 # Assert response body for update_volume method68 self.assertEqual(volume[self.name_field],69 update_volume[self.name_field])...
DisplayUpdateTest.py
Source:DisplayUpdateTest.py
...8while True:9 10 cf.volume = i11 print(cf.volume)12 DT.update_volume()13 sleep(1)14 i+=115# DT.update_volume()16# sleep(5)17# DT.update_volume()18# sleep(5)19# DT.update_volume(70)20# sleep(5)21# DT.update_volume(50)22# sleep(5)23# DT.update_volume(40)24# sleep(5)25# DT.update_volume(30)26# sleep(5)27# DT.update_volume(20)28# sleep(5)29# DT.update_volume(10)30# sleep(5)31# DT.update_volume(1)32# sleep(5)33# DT.update_volume(0)34# sleep(5)35#36#...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!