Best Python code snippet using tempest_python
test_rest_service_pagination.py
Source: test_rest_service_pagination.py
...27 def test_blueprints_pagination(self):28 for i in range(10):29 self.client.blueprints.upload(resource('dsl/pagination.yaml'),30 'blueprint{0}'.format(i))31 self._test_pagination(self.client.blueprints.list)32 def test_deployments_pagination(self):33 for i in range(10):34 self.deploy(resource('dsl/pagination.yaml'))35 self._test_pagination(self.client.deployments.list)36 def test_deployment_modifications_pagination(self):37 deployment = self.deploy(resource('dsl/pagination.yaml'))38 # since we have set max_results to 9 for this test,39 # we can't add more than 9 modification to the modifications history40 for i in range(1, 11):41 modification = self.client.deployment_modifications.start(42 deployment_id=deployment.id,43 nodes={'node': {'instances': i}})44 self.client.deployment_modifications.finish(modification.id)45 self._test_pagination(partial(46 self.client.deployment_modifications.list,47 deployment_id=deployment.id))48 def test_executions_pagination(self):49 deployment = self.deploy(resource('dsl/pagination.yaml'))50 for i in range(5):51 self.execute_workflow('install', deployment.id)52 self.execute_workflow('uninstall', deployment.id)53 total_executions = 11 # create_deployment_environment + 5 install/un54 self._test_pagination(partial(self.client.executions.list,55 deployment_id=deployment.id),56 total=total_executions)57 def test_nodes_pagination(self):58 deployment = self.deploy(resource('dsl/pagination-nodes.yaml'))59 num_of_nodes = 960 self._test_pagination(partial(self.client.nodes.list,61 deployment_id=deployment.id),62 total=num_of_nodes)63 def test_node_instances_pagination(self):64 deployment = self.deploy(65 resource('dsl/pagination-node-instances.yaml'))66 partial_obj = partial(67 self.client.node_instances.list,68 deployment_id=deployment.id)69 num_of_nodes_instances = 970 self._test_pagination(partial_obj, total=num_of_nodes_instances)71 def test_plugins_pagination(self):72 for i in range(1, 11):73 tmpdir = tempfile.mkdtemp(prefix='test-pagination-')74 with open(os.path.join(tmpdir, 'setup.py'), 'w') as f:75 f.write('from setuptools import setup\n')76 f.write('setup(name="cloudify-script-plugin", version={0})'77 .format(i))78 wagon_path = wagon.create(79 tmpdir, archive_destination_dir=tmpdir,80 # mark the wagon as windows-only, so that the manager doesn't81 # attempt to install it - which would be irrelevant for this82 # test, but add additional flakyness and runtime83 wheel_args=['--build-option', '--plat-name=win'])84 yaml_path = resource('plugins/plugin.yaml')85 with utils.zip_files([wagon_path, yaml_path]) as zip_path:86 self.client.plugins.upload(zip_path)87 shutil.rmtree(tmpdir)88 self._test_pagination(self.client.plugins.list)89 def _test_pagination(self, list_func, total=10):90 self.wait_for_all_executions_to_end()91 all_results = list_func(_sort=['id'],92 _offset=0,93 _size=MAX_RESULT_FOR_TESTING).items94 num_all = len(all_results)95 self.assertLessEqual(num_all, MAX_RESULT_FOR_TESTING)96 # sanity97 for offset in range(num_all + 1):98 # inside loop range should take into consideration99 # the fact that `all_results` is not the all results,100 # we used pagination..101 for size in range(num_all + 1 - offset):102 response = list_func(_offset=offset, _size=size, _sort=['id'])103 self.assertEqual(response.metadata.pagination.total, total)...
test_list_pagination.py
Source: test_list_pagination.py
...14# * limitations under the License.15#16from manager_rest.test.infrastructure.base_list_test import BaseListTest17class ResourceListTestCase(BaseListTest):18 def _test_pagination(self, list_func, total, sort_keys=None):19 if sort_keys is None:20 sort_keys = ['id']21 all_results = list_func(_sort=sort_keys).items22 num_all = len(all_results)23 # sanity24 self.assertGreaterEqual(num_all, total)25 for offset in range(num_all + 1):26 for size in range(num_all + 1):27 response = list_func(_offset=offset, _size=size,28 _sort=sort_keys)29 self.assertEqual(response.metadata.pagination.total, num_all)30 self.assertEqual(response.metadata.pagination.offset, offset)31 self.assertEqual(response.metadata.pagination.size, size)32 self.assertEqual(response.items,33 all_results[offset:offset + size])34 def test_deployments_list_paginated(self):35 self._put_n_deployments(id_prefix='test', number_of_deployments=4)36 self._test_pagination(self.client.deployments.list, 4,37 sort_keys=['id', 'blueprint_id'])38 def test_blueprints_list_paginated(self):39 self._put_n_deployments(id_prefix='test', number_of_deployments=2)40 self._test_pagination(self.client.blueprints.list, 2)41 def test_executions_list_paginated(self):42 self._put_n_deployments(id_prefix='test', number_of_deployments=2)43 self._test_pagination(self.client.executions.list, 2,44 sort_keys=['id', 'deployment_id',45 'blueprint_id'])46 def test_nodes_list_paginated(self):47 self._put_n_deployments(id_prefix='test', number_of_deployments=3)48 self._test_pagination(self.client.nodes.list, 6,49 sort_keys=['id', 'deployment_id',50 'blueprint_id'])51 def test_node_instances_list_paginated(self):52 self._put_n_deployments(id_prefix='test', number_of_deployments=3)53 self._test_pagination(self.client.node_instances.list, 6,54 sort_keys=['id', 'deployment_id'])55 def test_deployment_modifications_list_paginated(self):56 deployments = self._put_n_deployments(57 id_prefix='test', number_of_deployments=2)58 for dep in deployments:59 self._put_deployment_modification(dep)60 self._test_pagination(self.client.deployment_modifications.list, 2,61 sort_keys=['id', 'deployment_id'])62 def test_plugins_list_paginated(self):63 self._put_n_plugins(number_of_plugins=3)64 self._test_pagination(self.client.plugins.list, 3)65 def test_snapshots_list_paginated(self):66 self._put_n_snapshots(3)...
test_pagination.py
Source: test_pagination.py
...29 """Set up class."""30 cls.publishers = factories.PublisherFactory.create_batch(40)31 cls.books = factories.BookFactory.create_batch(40)32 call_command('search_index', '--rebuild', '-f')33 def _test_pagination(self):34 """Test pagination."""35 self.authenticate()36 publishers_url = reverse('publisherdocument-list', kwargs={})37 books_url = reverse('bookdocument-list', kwargs={})38 data = {}39 invalid_page_url = books_url + '?page=3&page_size=30'40 invalid_response = self.client.get(invalid_page_url, data)41 self.assertEqual(42 invalid_response.status_code,43 status.HTTP_404_NOT_FOUND44 )45 valid_page_url = publishers_url + '?limit=5&offset=8'46 # Check if response now is valid47 valid_response = self.client.get(valid_page_url, data)48 self.assertEqual(valid_response.status_code, status.HTTP_200_OK)49 # Check totals50 self.assertEqual(len(valid_response.data['results']), 5)51 def test_pagination(self):52 """Test pagination."""53 return self._test_pagination()54if __name__ == '__main__':...
Check out the latest blogs from LambdaTest on this topic:
These days, development teams depend heavily on feedback from automated tests to evaluate the quality of the system they are working on.
I think that probably most development teams describe themselves as being “agile” and probably most development teams have standups, and meetings called retrospectives.There is also a lot of discussion about “agile”, much written about “agile”, and there are many presentations about “agile”. A question that is often asked is what comes after “agile”? Many testers work in “agile” teams so this question matters to us.
I routinely come across test strategy documents when working with customers. They are lengthy—100 pages or more—and packed with monotonous text that is routinely reused from one project to another. Yawn once more— the test halt and resume circumstances, the defect management procedure, entrance and exit criteria, unnecessary generic risks, and in fact, one often-used model replicates the requirements of textbook testing, from stress to systems integration.
To understand the agile testing mindset, we first need to determine what makes a team “agile.” To me, an agile team continually focuses on becoming self-organized and cross-functional to be able to complete any challenge they may face during a project.
When working on web automation with Selenium, I encountered scenarios where I needed to refresh pages from time to time. When does this happen? One scenario is that I needed to refresh the page to check that the data I expected to see was still available even after refreshing. Another possibility is to clear form data without going through each input individually.
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!!