Best Python code snippet using localstack_python
test_s3.py
Source:test_s3.py
...241 metadata_saved = self.s3_client.head_object(Bucket=bucket_name, Key=object_key)['Metadata']242 self.assertEqual(metadata, metadata_saved)243 # clean up244 self._delete_bucket(bucket_name, [object_key])245 def test_s3_object_expiry(self):246 # handle s3 object expiry247 # https://github.com/localstack/localstack/issues/1685248 bucket_name = 'test-%s' % short_uid()249 self.s3_client.create_bucket(Bucket=bucket_name)250 # put object251 object_key = 'key-with-metadata'252 metadata = {'test_meta_1': 'foo', '__meta_2': 'bar'}253 self.s3_client.put_object(Bucket=bucket_name, Key=object_key, Metadata=metadata, Body='foo',254 Expires=datetime.datetime.now(timezone('GMT')) - datetime.timedelta(hours=1))255 # try to fetch an object which is already expired256 self.assertRaises(Exception, self.s3_client.get_object, Bucket=bucket_name, Key=object_key.lower())257 self.s3_client.put_object(Bucket=bucket_name, Key=object_key, Metadata=metadata, Body='foo',258 Expires=datetime.datetime.now(timezone('GMT')) + datetime.timedelta(hours=1))259 # try to fetch has not been expired yet....
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!!