Best Python code snippet using localstack_python
test_s3.py
Source:test_s3.py
...58 metadata_saved = s3_client.head_object(Bucket=s3_bucket, Key=object_key)["Metadata"]59 # note that casing is removed (since headers are case-insensitive)60 assert metadata_saved == {"test_meta_1": "foo", "__meta_2": "bar"}61 @pytest.mark.aws_validated62 def test_upload_file_multipart(self, s3_client, s3_bucket, tmpdir):63 key = "my-key"64 # https://boto3.amazonaws.com/v1/documentation/api/latest/guide/s3.html#multipart-transfers65 config = TransferConfig(multipart_threshold=5 * KB, multipart_chunksize=1 * KB)66 file = tmpdir / "test-file.bin"67 data = b"1" * (6 * KB) # create 6 kilobytes of ones68 file.write(data=data, mode="w")69 s3_client.upload_file(70 Bucket=s3_bucket, Key=key, Filename=str(file.realpath()), Config=config71 )72 obj = s3_client.get_object(Bucket=s3_bucket, Key=key)73 assert obj["Body"].read() == data, f"body did not contain expected data {obj}"74class TestS3PresignedUrl:75 """76 These tests pertain to S3's presigned URL feature....
marketing_file_service_test.py
Source:marketing_file_service_test.py
...61 )62 res = self.api.upload_file(upload_file_request_wrapper)63 print(res)64 assert res.header.status == 065 def test_upload_file_multipart(self):66 file = open("/tmp/b.txt", mode="rb")67 # 请填åèªå·±çä¿¡æ¯68 header = ApiRequestHeader(69 token="xxxxx",70 username="xxxxx",71 password="xxxxx",72 target="xxxxx",73 _spec_property_naming=True74 )75 body = UploadFileRequest(76 file=file,77 params=UploadFileParams(fileName="test" + str(time.time()) + ".txt",78 fileType="txt",79 storeType="temp",...
test_api_media_object.py
Source:test_api_media_object.py
...29 # invalid media id raises exception30 with self.assertRaisesRegex(ValueError, "invalid media: oops"):31 api_media_object.media_to_media_id("oops")32 @requests_mock.Mocker()33 def test_upload_file_multipart(self, rm):34 api_config = mock.Mock()35 api_config.verbosity = 236 api_media_object = ApiMediaObject(api_config, mock.Mock())37 test_url = "https://test_upload_host/test_upload_path"38 test_data = {"test_key": "test_value"}39 rm.post(test_url) # mock the post request40 # mock the upload of a file with the contents "pinteresty video"41 with mock.patch(42 "builtins.open", mock.mock_open(read_data="pinteresty video")43 ) as mock_open:44 api_media_object.upload_file_multipart(test_url, "test_file", test_data)45 mock_open.assert_called_once_with("test_file", "rb")46 # check to verify that the posted form data47 self.assertRegex(...
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!!