Best Python code snippet using localstack_python
client_test.py
Source:client_test.py
...84 request = messages.UploadPartRequest(85 self.test_bucket, object, upload_id, part_number, contents)86 self.assertRaises(messages.S3ClientError, self.client.upload_part, request)87 try:88 self.client.upload_part(request)89 except Exception as e:90 self.assertIsInstance(e, messages.S3ClientError)91 self.assertEqual(e.code, 404)92 def test_copy_nonexistent(self):93 src_key = self.test_path + 'not_a_real_file_does_not_exist'94 dest_key = self.test_path + 'destination_file_location'95 request = messages.CopyRequest(96 self.test_bucket, src_key, self.test_bucket, dest_key)97 with self.assertRaises(messages.S3ClientError) as e:98 self.client.copy(request)99 self.assertEqual(e.exception.code, 404)100 def test_upload_part_bad_number(self):101 object = self.test_path + 'upload_part'102 contents = os.urandom(1024)103 request = messages.UploadRequest(self.test_bucket, object, None)104 response = self.client.create_multipart_upload(request)105 upload_id = response.upload_id106 part_number = 0.5107 request = messages.UploadPartRequest(108 self.test_bucket, object, upload_id, part_number, contents)109 self.assertRaises(messages.S3ClientError, self.client.upload_part, request)110 try:111 response = self.client.upload_part(request)112 except Exception as e:113 self.assertIsInstance(e, messages.S3ClientError)114 self.assertEqual(e.code, 400)115 def test_complete_multipart_upload_too_small(self):116 object = self.test_path + 'upload_part'117 request = messages.UploadRequest(self.test_bucket, object, None)118 response = self.client.create_multipart_upload(request)119 upload_id = response.upload_id120 part_number = 1121 contents_1 = os.urandom(1024)122 request_1 = messages.UploadPartRequest(123 self.test_bucket, object, upload_id, part_number, contents_1)124 response_1 = self.client.upload_part(request_1)125 part_number = 2126 contents_2 = os.urandom(1024)127 request_2 = messages.UploadPartRequest(128 self.test_bucket, object, upload_id, part_number, contents_2)129 response_2 = self.client.upload_part(request_2)130 parts = [{131 'PartNumber': 1, 'ETag': response_1.etag132 }, {133 'PartNumber': 2, 'ETag': response_2.etag134 }]135 complete_request = messages.CompleteMultipartUploadRequest(136 self.test_bucket, object, upload_id, parts)137 try:138 self.client.complete_multipart_upload(complete_request)139 except Exception as e:140 self.assertIsInstance(e, messages.S3ClientError)141 self.assertEqual(e.code, 400)142 def test_complete_multipart_upload_too_many(self):143 object = self.test_path + 'upload_part'144 request = messages.UploadRequest(self.test_bucket, object, None)145 response = self.client.create_multipart_upload(request)146 upload_id = response.upload_id147 part_number = 1148 contents_1 = os.urandom(5 * 1024)149 request_1 = messages.UploadPartRequest(150 self.test_bucket, object, upload_id, part_number, contents_1)151 response_1 = self.client.upload_part(request_1)152 part_number = 2153 contents_2 = os.urandom(1024)154 request_2 = messages.UploadPartRequest(155 self.test_bucket, object, upload_id, part_number, contents_2)156 response_2 = self.client.upload_part(request_2)157 parts = [158 {159 'PartNumber': 1, 'ETag': response_1.etag160 },161 {162 'PartNumber': 2, 'ETag': response_2.etag163 },164 {165 'PartNumber': 3, 'ETag': 'fake-etag'166 },167 ]168 complete_request = messages.CompleteMultipartUploadRequest(169 self.test_bucket, object, upload_id, parts)170 try:...
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!!