Created
March 14, 2015 23:41
-
-
Save spulec/14cdbbb4170000841bd6 to your computer and use it in GitHub Desktop.
flask moto test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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