Best Python code snippet using tempest_python
test_object_temp_url.py
Source: test_object_temp_url.py
...67 self.object_client.create_object(self.container_name,68 self.object_name, self.data)69 def _get_expiry_date(self, expiration_time=1000):70 return int(time.time() + expiration_time)71 def _get_temp_url(self, container, object_name, method, expires,72 key):73 """Create the temporary URL."""74 path = "%s/%s/%s" % (75 urlparse.urlparse(self.object_client.base_url).path,76 container, object_name)77 hmac_body = '%s\n%s\n%s' % (method, expires, path)78 sig = hmac.new(key, hmac_body, hashlib.sha1).hexdigest()79 url = "%s/%s?temp_url_sig=%s&temp_url_expires=%s" % (container,80 object_name,81 sig, expires)82 return url83 @attr(type='gate')84 def test_get_object_using_temp_url(self):85 expires = self._get_expiry_date()86 # get a temp URL for the created object87 url = self._get_temp_url(self.container_name,88 self.object_name, "GET",89 expires, self.key)90 # trying to get object using temp url within expiry time91 resp, body = self.object_client.get_object_using_temp_url(url)92 self.assertIn(int(resp['status']), HTTP_SUCCESS)93 self.assertHeaders(resp, 'Object', 'GET')94 self.assertEqual(body, self.data)95 # Testing a HEAD on this Temp URL96 resp, body = self.object_client.head(url)97 self.assertIn(int(resp['status']), HTTP_SUCCESS)98 self.assertHeaders(resp, 'Object', 'HEAD')99 @attr(type='gate')100 def test_get_object_using_temp_url_key_2(self):101 key2 = 'Meta2-'102 metadata = {'Temp-URL-Key-2': key2}103 self.account_client.create_account_metadata(metadata=metadata)104 self.account_client_metadata, _ = \105 self.account_client.list_account_metadata()106 self.assertIn('x-account-meta-temp-url-key-2',107 self.account_client_metadata)108 expires = self._get_expiry_date()109 url = self._get_temp_url(self.container_name,110 self.object_name, "GET",111 expires, key2)112 resp, body = self.object_client.get_object_using_temp_url(url)113 self.assertIn(int(resp['status']), HTTP_SUCCESS)114 self.assertEqual(body, self.data)115 @attr(type='gate')116 def test_put_object_using_temp_url(self):117 # make sure the metadata has been set118 new_data = data_utils.arbitrary_string(119 size=len(self.object_name),120 base_text=data_utils.rand_name(name="random"))121 expires = self._get_expiry_date()122 url = self._get_temp_url(self.container_name,123 self.object_name, "PUT",124 expires, self.key)125 # trying to put random data in the object using temp url126 resp, body = self.object_client.put_object_using_temp_url(127 url, new_data)128 self.assertIn(int(resp['status']), HTTP_SUCCESS)129 self.assertHeaders(resp, 'Object', 'PUT')130 # Testing a HEAD on this Temp URL131 resp, body = self.object_client.head(url)132 self.assertIn(int(resp['status']), HTTP_SUCCESS)133 self.assertHeaders(resp, 'Object', 'HEAD')134 # Validate that the content of the object has been modified135 url = self._get_temp_url(self.container_name,136 self.object_name, "GET",137 expires, self.key)138 _, body = self.object_client.get_object_using_temp_url(url)139 self.assertEqual(body, new_data)140 @attr(type=['gate', 'negative'])141 def test_get_object_after_expiration_time(self):142 expires = self._get_expiry_date(1)143 # get a temp URL for the created object144 url = self._get_temp_url(self.container_name,145 self.object_name, "GET",146 expires, self.key)147 # temp URL is valid for 1 seconds, let's wait 2148 time.sleep(2)149 self.assertRaises(exceptions.Unauthorized,150 self.object_client.get_object_using_temp_url,...
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!!