Best Python code snippet using tempest_python
test_volumes_snapshots_list.py
Source:test_volumes_snapshots_list.py
...26 cls.name_field = cls.special_fields['name_field']27 # Create snapshots with params28 for _ in range(2):29 cls.snapshot = cls.create_snapshot(cls.volume_origin['id'])30 def _list_by_param_values_and_assert(self, with_detail=False, **params):31 """list or list_details with given params and validates result."""32 fetched_snap_list = self.snapshots_client.list_snapshots(33 detail=with_detail, **params)['snapshots']34 # Validating params of fetched snapshots35 for snap in fetched_snap_list:36 for key in params:37 msg = "Failed to list snapshots %s by %s" % \38 ('details' if with_detail else '', key)39 self.assertEqual(params[key], snap[key], msg)40 def _list_snapshots_by_param_limit(self, limit, expected_elements):41 """list snapshots by limit param"""42 # Get snapshots list using limit parameter43 fetched_snap_list = self.snapshots_client.list_snapshots(44 limit=limit)['snapshots']45 # Validating filtered snapshots length equals to expected_elements46 self.assertEqual(expected_elements, len(fetched_snap_list))47 @decorators.idempotent_id('59f41f43-aebf-48a9-ab5d-d76340fab32b')48 def test_snapshots_list_with_params(self):49 """list snapshots with params."""50 # Verify list snapshots by display_name filter51 params = {self.name_field: self.snapshot[self.name_field]}52 self._list_by_param_values_and_assert(**params)53 # Verify list snapshots by status filter54 params = {'status': 'available'}55 self._list_by_param_values_and_assert(**params)56 # Verify list snapshots by status and display name filter57 params = {'status': 'available',58 self.name_field: self.snapshot[self.name_field]}59 self._list_by_param_values_and_assert(**params)60 @decorators.idempotent_id('220a1022-1fcd-4a74-a7bd-6b859156cda2')61 def test_snapshots_list_details_with_params(self):62 """list snapshot details with params."""63 # Verify list snapshot details by display_name filter64 params = {self.name_field: self.snapshot[self.name_field]}65 self._list_by_param_values_and_assert(with_detail=True, **params)66 # Verify list snapshot details by status filter67 params = {'status': 'available'}68 self._list_by_param_values_and_assert(with_detail=True, **params)69 # Verify list snapshot details by status and display name filter70 params = {'status': 'available',71 self.name_field: self.snapshot[self.name_field]}72 self._list_by_param_values_and_assert(with_detail=True, **params)73 @decorators.idempotent_id('db4d8e0a-7a2e-41cc-a712-961f6844e896')74 def test_snapshot_list_param_limit(self):75 # List returns limited elements76 self._list_snapshots_by_param_limit(limit=1, expected_elements=1)77 @decorators.idempotent_id('a1427f61-420e-48a5-b6e3-0b394fa95400')78 def test_snapshot_list_param_limit_equals_infinite(self):79 # List returns all elements when request limit exceeded80 # snapshots number81 snap_list = self.snapshots_client.list_snapshots()['snapshots']82 self._list_snapshots_by_param_limit(limit=100000,83 expected_elements=len(snap_list))84 @decorators.skip_because(bug='1540893')85 @decorators.idempotent_id('e3b44b7f-ae87-45b5-8a8c-66110eb24d0a')86 def test_snapshot_list_param_limit_equals_zero(self):...
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!!