Exemplo n.º 1
0
def test_app():
    app = Flask(__name__)
    app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///:memory:"
    app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = True
    app.config["TESTING"] = True

    _db.init_app(app)

    with app.app_context():
        _db.create_all()
        yield app
        _db.drop_all()
Exemplo n.º 2
0
def test_app():
    """Set up test Flask application."""

    # Set up Flask app
    app = Flask(__name__)
    # We will create database in memory
    # That way, we don't worry about after cleaning/removing it after running tests
    app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///:memory:"
    app.config["TESTING"] = True
    app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = True

    _db.init_app(app)

    with app.app_context():
        # Create database tables
        _db.create_all()
        yield app
        # Our database is stored in memory so the following line is not needed
        # I'm using it to show you how to clean up after your tests
        _db.drop_all()
Exemplo n.º 3
0
"""Main file of our application.

When ran with:
$ python run.py
it will reset the database and start the webserver.
"""

from todo import app, db

if __name__ == "__main__":

    db.drop_all()
    db.create_all()

    app.run(host="0.0.0.0")
Exemplo n.º 4
0
 def tearDown(self):
     db.session.remove()
     db.drop_all()
Exemplo n.º 5
0
 def tearDown(self):
     db.session.remove()
     db.drop_all()
Exemplo n.º 6
0
def app_inst():
    app.config.from_object("config.TestConfig")
    db.create_all()
    yield app
    db.drop_all()
Exemplo n.º 7
0
 def tearDown(self):
     db.session.remove()
     db.drop_all()
     self.app_context.pop()