Best Python code snippet using localstack_python
test_s3.py
Source:test_s3.py
...28 self.assertIsNone(url2, 'Should not get a redirect URL without success_action_redirect')29 key3, url3 = s3_listener.find_multipart_redirect_url(data3, headers)30 self.assertIsNone(key3, 'Should not get a key without provided key')31 self.assertIsNone(url3, 'Should not get a redirect URL without provided key')32 def test_expand_multipart_filename(self):33 headers = {'Host': '10.0.1.19:4572', 'User-Agent': 'curl/7.51.0',34 'Accept': '*/*', 'Content-Length': '992', 'Expect': '100-continue',35 'Content-Type': 'multipart/form-data; boundary=------------------------3c48c744237517ac'}36 data1 = (b'--------------------------3c48c744237517ac\r\nContent-Disposition: form-data; name="key"\r\n\r\n'37 b'uploads/20170826T181315.679087009Z/upload/${filename}\r\n--------------------------3c48c744237517ac'38 b'\r\nContent-Disposition: form-data; name="AWSAccessKeyId"\r\n\r\nWHAT\r\n--------------------------'39 b'3c48c744237517ac\r\nContent-Disposition: form-data; name="policy"\r\n\r\nNO\r\n--------------------'40 b'------3c48c744237517ac\r\nContent-Disposition: form-data; name="signature"\r\n\r\nYUP\r\n----------'41 b'----------------3c48c744237517ac\r\nContent-Disposition: form-data; name="acl"\r\n\r\nprivate\r\n--'42 b'------------------------3c48c744237517ac\r\nContent-Disposition: form-data; name="success_action_re'43 b'direct"\r\n\r\nhttp://127.0.0.1:5000/\r\n--------------------------3c48c744237517ac\r\nContent-Disp'44 b'osition: form-data; name="file"; filename="pixel.png"\r\nContent-Type: application/octet-stream\r\n'45 b'\r\n\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x01\x00\x00\x00\x01\x08\x06\x00\x00\x00\x1f\x15'46 b'\xc4\x89\x00\x00\x00\x19tEXtSoftware\x00Adobe ImageReadyq\xc9e<\x00\x00\x00\x0eIDATx\xdabb\x00\x02'47 b'\x80\x00\x03\x00\x00\x0f\x00\x03`|\xce\xe9\x00\x00\x00\x00IEND\xaeB`\x82\r\n-----------------------'48 b'---3c48c744237517ac--\r\n')49 data2 = (b'--------------------------3c48c744237517ac\r\nContent-Disposition: form-data; name="key"\r\n\r\n'50 b'uploads/20170826T181315.679087009Z/upload/pixel.png\r\n--------------------------3c48c744237517ac'51 b'\r\nContent-Disposition: form-data; name="AWSAccessKeyId"\r\n\r\nWHAT\r\n--------------------------'52 b'3c48c744237517ac\r\nContent-Disposition: form-data; name="policy"\r\n\r\nNO\r\n--------------------'53 b'------3c48c744237517ac\r\nContent-Disposition: form-data; name="signature"\r\n\r\nYUP\r\n----------'54 b'----------------3c48c744237517ac\r\nContent-Disposition: form-data; name="acl"\r\n\r\nprivate\r\n--'55 b'------------------------3c48c744237517ac\r\nContent-Disposition: form-data; name="success_action_re'56 b'direct"\r\n\r\nhttp://127.0.0.1:5000/\r\n--------------------------3c48c744237517ac\r\nContent-Disp'57 b'osition: form-data; name="file"; filename="pixel.png"\r\nContent-Type: application/octet-stream\r\n'58 b'\r\n\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x01\x00\x00\x00\x01\x08\x06\x00\x00\x00\x1f\x15'59 b'\xc4\x89\x00\x00\x00\x19tEXtSoftware\x00Adobe ImageReadyq\xc9e<\x00\x00\x00\x0eIDATx\xdabb\x00\x02'60 b'\x80\x00\x03\x00\x00\x0f\x00\x03`|\xce\xe9\x00\x00\x00\x00IEND\xaeB`\x82\r\n-----------------------'61 b'---3c48c744237517ac--\r\n')62 data3 = (u'--------------------------3c48c744237517ac\r\nContent-Disposition: form-data; name="key"\r\n\r\n'63 u'uploads/20170826T181315.679087009Z/upload/${filename}\r\n--------------------------3c48c744237517ac'64 u'\r\nContent-Disposition: form-data; name="AWSAccessKeyId"\r\n\r\nWHAT\r\n--------------------------'65 u'3c48c744237517ac\r\nContent-Disposition: form-data; name="policy"\r\n\r\nNO\r\n--------------------'66 u'------3c48c744237517ac\r\nContent-Disposition: form-data; name="signature"\r\n\r\nYUP\r\n----------'67 u'----------------3c48c744237517ac\r\nContent-Disposition: form-data; name="acl"\r\n\r\nprivate\r\n--'68 u'------------------------3c48c744237517ac\r\nContent-Disposition: form-data; name="success_action_re'69 u'direct"\r\n\r\nhttp://127.0.0.1:5000/\r\n--------------------------3c48c744237517ac\r\nContent-Disp'70 u'osition: form-data; name="file"; filename="pixel.txt"\r\nContent-Type: text/plain\r\n\r\nHello World'71 u'\r\n--------------------------3c48c744237517ac--\r\n')72 expanded1 = s3_listener.expand_multipart_filename(data1, headers)73 self.assertIsNot(expanded1, data1, 'Should have changed content of data with filename to interpolate')74 self.assertIn(b'uploads/20170826T181315.679087009Z/upload/pixel.png', expanded1,75 'Should see the interpolated filename')76 expanded2 = s3_listener.expand_multipart_filename(data2, headers)77 self.assertIs(expanded2, data2, 'Should not have changed content of data with no filename to interpolate')78 expanded3 = s3_listener.expand_multipart_filename(data3, headers)79 self.assertIsNot(expanded3, data3, 'Should have changed content of string data with filename to interpolate')80 self.assertIn(b'uploads/20170826T181315.679087009Z/upload/pixel.txt', expanded3,...
34135_test_s3.py
Source:34135_test_s3.py
...28 self.assertIsNone(url2, 'Should not get a redirect URL without success_action_redirect')29 key3, url3 = s3_listener.find_multipart_redirect_url(data3, headers)30 self.assertIsNone(key3, 'Should not get a key without provided key')31 self.assertIsNone(url3, 'Should not get a redirect URL without provided key')32 def test_expand_multipart_filename(self):33 headers = {'Host': '10.0.1.19:4572', 'User-Agent': 'curl/7.51.0',34 'Accept': '*/*', 'Content-Length': '992', 'Expect': '100-continue',35 'Content-Type': 'multipart/form-data; boundary=------------------------3c48c744237517ac'}36 data1 = (b'--------------------------3c48c744237517ac\r\nContent-Disposition: form-data; name="key"\r\n\r\n'37 b'uploads/20170826T181315.679087009Z/upload/${filename}\r\n--------------------------3c48c744237517ac'38 b'\r\nContent-Disposition: form-data; name="AWSAccessKeyId"\r\n\r\nWHAT\r\n--------------------------'39 b'3c48c744237517ac\r\nContent-Disposition: form-data; name="policy"\r\n\r\nNO\r\n--------------------'40 b'------3c48c744237517ac\r\nContent-Disposition: form-data; name="signature"\r\n\r\nYUP\r\n----------'41 b'----------------3c48c744237517ac\r\nContent-Disposition: form-data; name="acl"\r\n\r\nprivate\r\n--'42 b'------------------------3c48c744237517ac\r\nContent-Disposition: form-data; name="success_action_re'43 b'direct"\r\n\r\nhttp://127.0.0.1:5000/\r\n--------------------------3c48c744237517ac\r\nContent-Disp'44 b'osition: form-data; name="file"; filename="pixel.png"\r\nContent-Type: application/octet-stream\r\n'45 b'\r\n\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x01\x00\x00\x00\x01\x08\x06\x00\x00\x00\x1f\x15'46 b'\xc4\x89\x00\x00\x00\x19tEXtSoftware\x00Adobe ImageReadyq\xc9e<\x00\x00\x00\x0eIDATx\xdabb\x00\x02'47 b'\x80\x00\x03\x00\x00\x0f\x00\x03`|\xce\xe9\x00\x00\x00\x00IEND\xaeB`\x82\r\n-----------------------'48 b'---3c48c744237517ac--\r\n')49 data2 = (b'--------------------------3c48c744237517ac\r\nContent-Disposition: form-data; name="key"\r\n\r\n'50 b'uploads/20170826T181315.679087009Z/upload/pixel.png\r\n--------------------------3c48c744237517ac'51 b'\r\nContent-Disposition: form-data; name="AWSAccessKeyId"\r\n\r\nWHAT\r\n--------------------------'52 b'3c48c744237517ac\r\nContent-Disposition: form-data; name="policy"\r\n\r\nNO\r\n--------------------'53 b'------3c48c744237517ac\r\nContent-Disposition: form-data; name="signature"\r\n\r\nYUP\r\n----------'54 b'----------------3c48c744237517ac\r\nContent-Disposition: form-data; name="acl"\r\n\r\nprivate\r\n--'55 b'------------------------3c48c744237517ac\r\nContent-Disposition: form-data; name="success_action_re'56 b'direct"\r\n\r\nhttp://127.0.0.1:5000/\r\n--------------------------3c48c744237517ac\r\nContent-Disp'57 b'osition: form-data; name="file"; filename="pixel.png"\r\nContent-Type: application/octet-stream\r\n'58 b'\r\n\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x01\x00\x00\x00\x01\x08\x06\x00\x00\x00\x1f\x15'59 b'\xc4\x89\x00\x00\x00\x19tEXtSoftware\x00Adobe ImageReadyq\xc9e<\x00\x00\x00\x0eIDATx\xdabb\x00\x02'60 b'\x80\x00\x03\x00\x00\x0f\x00\x03`|\xce\xe9\x00\x00\x00\x00IEND\xaeB`\x82\r\n-----------------------'61 b'---3c48c744237517ac--\r\n')62 data3 = (u'--------------------------3c48c744237517ac\r\nContent-Disposition: form-data; name="key"\r\n\r\n'63 u'uploads/20170826T181315.679087009Z/upload/${filename}\r\n--------------------------3c48c744237517ac'64 u'\r\nContent-Disposition: form-data; name="AWSAccessKeyId"\r\n\r\nWHAT\r\n--------------------------'65 u'3c48c744237517ac\r\nContent-Disposition: form-data; name="policy"\r\n\r\nNO\r\n--------------------'66 u'------3c48c744237517ac\r\nContent-Disposition: form-data; name="signature"\r\n\r\nYUP\r\n----------'67 u'----------------3c48c744237517ac\r\nContent-Disposition: form-data; name="acl"\r\n\r\nprivate\r\n--'68 u'------------------------3c48c744237517ac\r\nContent-Disposition: form-data; name="success_action_re'69 u'direct"\r\n\r\nhttp://127.0.0.1:5000/\r\n--------------------------3c48c744237517ac\r\nContent-Disp'70 u'osition: form-data; name="file"; filename="pixel.txt"\r\nContent-Type: text/plain\r\n\r\nHello World'71 u'\r\n--------------------------3c48c744237517ac--\r\n')72 expanded1 = s3_listener.expand_multipart_filename(data1, headers)73 self.assertIsNot(expanded1, data1, 'Should have changed content of data with filename to interpolate')74 self.assertIn(b'uploads/20170826T181315.679087009Z/upload/pixel.png', expanded1,75 'Should see the interpolated filename')76 expanded2 = s3_listener.expand_multipart_filename(data2, headers)77 self.assertIs(expanded2, data2, 'Should not have changed content of data with no filename to interpolate')78 expanded3 = s3_listener.expand_multipart_filename(data3, headers)79 self.assertIsNot(expanded3, data3, 'Should have changed content of string data with filename to interpolate')80 self.assertIn(b'uploads/20170826T181315.679087009Z/upload/pixel.txt', expanded3,...
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!!