0

By any chance anyone can point me to correct direction? I'm trying to run the moto (https://github.com/spulec/moto) as backend service so that i can test out my application. I am able to run the moto service and load the webpage of the moto-api as suggested (http://localhost:5000/moto-api/#).

I have the question, how do i setup all my test bucket and instances for this backend service?

Thanks.

jen1982
  • 67
  • 2
  • 11
  • refer: http://docs.getmoto.org/en/latest/docs/getting_started.html – Mahesh Karia Mar 17 '20 at 11:33
  • Thanks Mahesh, yes, i think they are similar with the github page as well. But in that link didn't mention how to setup the bucket or create running instant etc? Do i need to put something in ~/.boto file?? thanks. – jen1982 Mar 17 '20 at 11:51

1 Answers1

1

If the application under test assumes that the bucket exists, you can simply create the bucket as part of the test:

@mock_s3
def test_something():
    client = boto3.client("s3", endpoint_url="http://localhost:5000")
    client.create_bucket(Bucket="test-bucket")
    # Call whatever function/business logic you're trying to test, that assumes a bucket called 'test-bucket' exists
    something()
Bert Blommers
  • 1,788
  • 2
  • 13
  • 19