Best Python code snippet using localstack_python
test_s3.py
Source:test_s3.py  
...266        download_file_object = BytesIO(downloaded_object['Body'].read())267        with gzip.GzipFile(fileobj=download_file_object, mode='rb') as filestream:268            downloaded_data = filestream.read().decode('utf-8')269        assert downloaded_data == data, '{} != {}'.format(downloaded_data, data)270    def test_set_external_hostname(self):271        bucket_name = 'test-bucket-%s' % short_uid()272        key = 'test.file'273        hostname_before = config.HOSTNAME_EXTERNAL274        config.HOSTNAME_EXTERNAL = 'foobar'275        try:276            content = 'test content 123'277            acl = 'public-read'278            self.s3_client.create_bucket(Bucket=bucket_name)279            # upload file280            response = self._perform_multipart_upload(bucket=bucket_name, key=key, data=content, acl=acl)281            expected_url = '%s://%s:%s/%s/%s' % (get_service_protocol(), config.HOSTNAME_EXTERNAL,282                config.PORT_S3, bucket_name, key)283            self.assertEqual(expected_url, response['Location'])284            # fix object ACL - currently not directly support for multipart uploads...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!!
