def setUp(self): mock_s3 = moto.mock_s3() mock_s3.start() self.addCleanup(mock_s3.stop) self.s3 = boto.connect_s3() self.s3.create_bucket('test_s3_bucket')
def s3_client(): mock_s3 = moto.mock_s3() mock_s3.start() client = boto3.client('s3') client.create_bucket(Bucket=test_bucket_name) client.put_object(Bucket=test_bucket_name, Key=test_file_path, Body=test_nb_content) yield S3() try: client.delete_object(Bucket=test_bucket_name, Key=test_file_path) client.delete_object(Bucket=test_bucket_name, Key=test_file_path + '.txt') except Exception: pass mock_s3.stop()
def s3_client(): mock_s3 = moto.mock_s3() mock_s3.start() client = boto3.client('s3') client.create_bucket( Bucket=test_bucket_name, CreateBucketConfiguration={'LocationConstraint': 'us-west-2'}) client.put_object(Bucket=test_bucket_name, Key=test_file_path, Body=test_nb_content) client.put_object(Bucket=test_bucket_name, Key=test_empty_file_path, Body='') yield S3() try: client.delete_object(Bucket=test_bucket_name, Key=test_file_path) client.delete_object(Bucket=test_bucket_name, Key=test_file_path + '.txt') client.delete_object(Bucket=test_bucket_name, Key=test_empty_file_path) except Exception: pass mock_s3.stop()