I am writing unit test for the function below which is inside s3_util file in util package. The below code moves a file on S3 from a given file_path to a given target_path:
move_file(file_path, target_path, bucket)
s3=boto3.resource('s3')
copy_source = { 'Bucket': bucket, 'key' : file_path}
file_name = file.path.split('-1')[-1]
s3.meta.client.copy(copy_source, bucket, target_file + file_name)
boto3.client('s3').delete_object(Bucket=bucket, key=key_path)
The unit test code which I am attempting is as below:
@patch('util.s3_util.boto3.client)
def test_move(self, mock_obj)
move_file('test-file-path','test-target-path','test-bucket')
mock_obj.called
How do I change the above code to test the line which has the s3.meta.client.copy call?
I came across the below related link. Do I have to use mock_s3 for this as below or there is some other way to test the s3.meta.client.copy call?
upload a test file using moto and boto3
Thanks