I'm currently learning how to write unit test for boto3
I'm trying to follow the moto
documentation and have written a few lines for the unit test but it gave me error:
@mock_s3
def test_upload_to_s3(self):
conn = boto3.resource('s3')
# We need to create the bucket since this is all in Moto's 'virtual' AWS account
conn.create_bucket(Bucket='mybucket')
instance = s3_upload.upload_to_s3('test.csv', 'mybucket',
'test.csv')
instance.upload_to_s3()
body = conn.Object(test.csv).get()['Body'].read().decode("utf-8")
assert body == 'test.csv'
if __name__ == '__main__':
unittest.main()
Error:AttributeError: 'NoneType' object has no attribute 'upload_to_s3'
I've been struggling with it for a whole day now, can someone gave me an example or some hints, thanks in advance.