Skip to content

Instantly share code, notes, and snippets.

@spulec
Created March 14, 2015 23:41
Show Gist options
  • Save spulec/14cdbbb4170000841bd6 to your computer and use it in GitHub Desktop.
Save spulec/14cdbbb4170000841bd6 to your computer and use it in GitHub Desktop.
flask moto test
from flask import Flask
app = Flask(__name__)
import boto
from moto import mock_s3
@app.route("/")
def hello():
conn = boto.connect_s3('the_key', 'the_secret')
bucket = conn.create_bucket('mybucket')
return "Hello World!"
import unittest
class FlaskrTestCase(unittest.TestCase):
def setUp(self):
app.config['TESTING'] = True
self.app = app.test_client()
@mock_s3
def test_response(self):
rv = self.app.get('/')
assert rv.data == "Hello World!"
if __name__ == '__main__':
unittest.main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment