def setUp(self): app.testing = True self.app = app.test_client() with app.test_request_context(): db.create_all() user = {"tipo": 'admin', "email": "*****@*****.**", "password": '******'} headers = {"Content-Type": 'application/json'} login = requests.post( 'https://choutuve-app-server.herokuapp.com/login', headers=headers, data=json.dumps(user)) self.token = login.text
def client(): with app.test_request_context(): yield TestApp(app)
import os import sys from flask import * from __init__ import app from flask.ext.sqlalchemy import SQLAlchemy # if you add blueprints, import their models as below from apps.example.models import * app.testing = True app.test_client() ctx = app.test_request_context() ctx.push() print "app and db have been imported." print "You have a test client: client,\nand a test request context: ctx"
def tearDown(self): with app.test_request_context(): db.drop_all()