Best Python code snippet using tempest_python
test_image_caching.py
Source: test_image_caching.py
...62 def _assertCheckQueues(self, queued_images):63 for image in self.cached_info:64 if self.cached_info[image] == 'queued':65 self.assertIn(image, queued_images)66 def _assertCheckCache(self, cached_images):67 cached_list = []68 for image in cached_images:69 cached_list.append(image['image_id'])70 for image in self.cached_info:71 if self.cached_info[image] == 'cached':72 self.assertIn(image, cached_list)73 @decorators.idempotent_id('4bf6adba-2f9f-47e9-a6d5-37f21ad4387c')74 def test_image_caching_cycle(self):75 """Test image cache APIs"""76 # Ensure that non-admin user is not allowed to perform caching77 # operations78 self.assertRaises(lib_exc.Forbidden,79 self.os_primary.image_cache_client.list_cache)80 # Check there is nothing is queued for cached by us81 output = self.os_admin.image_cache_client.list_cache()82 self._assertCheckQueues(output['queued_images'])83 self._assertCheckCache(output['cached_images'])84 # Non-existing image should raise NotFound exception85 self.assertRaises(lib_exc.NotFound,86 self.os_admin.image_cache_client.cache_queue,87 'non-existing-image-id')88 # Verify that we can not use queued image for queueing89 image = self.image_create_and_upload(name='queued', upload=False)90 self.assertRaises(lib_exc.BadRequest,91 self.os_admin.image_cache_client.cache_queue,92 image['id'])93 # Create one image94 image = self.image_create_and_upload(name='first',95 container_format='bare',96 disk_format='raw',97 visibility='private')98 self.assertEqual('active', image['status'])99 # Queue image for caching100 self.os_admin.image_cache_client.cache_queue(image['id'])101 self.cached_info[image['id']] = 'queued'102 # Verify that we have 1 image for queueing and 0 for caching103 output = self.os_admin.image_cache_client.list_cache()104 self._assertCheckQueues(output['queued_images'])105 self._assertCheckCache(output['cached_images'])106 # Wait for image caching107 LOG.info("Waiting for image %s to get cached", image['id'])108 caching = waiters.wait_for_caching(109 self.client,110 self.os_admin.image_cache_client,111 image['id'])112 self.cached_info[image['id']] = 'cached'113 # verify that we have image in cache and not in queued114 self._assertCheckQueues(caching['queued_images'])115 self._assertCheckCache(caching['cached_images'])116 # Verify that we can delete images from caching and queueing with117 # api call.118 self.os_admin.image_cache_client.cache_clear()119 output = self.os_admin.image_cache_client.list_cache()120 self.assertEqual(0, len(output['queued_images']))121 self.assertEqual(0, len(output['cached_images']))122 # Verify that invalid header value for target returns 400 response123 self.assertRaises(lib_exc.BadRequest,124 self.os_admin.image_cache_client.cache_clear,125 target="invalid")126 # Remove all data from local information...
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!!