def setUp(self): app.config['TESTING'] = True app.config['WTF_CSRF_ENABLED'] = False app.config['DEBUG'] = False app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///test.sqlite' self.app = app.test_client() db.drop_all() db.create_all()
def setUp(self): #set up before each run app.config['TESTING'] = True app.config['DEBUG'] = False app.config['WTF_CSRF_ENABLED'] = False app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + TEST_DB self.app = app.test_client() db.drop_all() db.create_all()
def setUp(self): ''' Set up the test settings as appropriate for Flask''' app.config['TESTING'] = True app.config['DEBUG'] = False app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///unit_tests.db' self.app = app.test_client() db.create_all() self.assertEqual(app.debug, False)
def setUp(self): # setup for the tests to check the functionality self.app = app.test_client() db.create_all() self.user = User(username="******", email="*****@*****.**", password="******") db.session.add(self.user) todo = Todo(title="Task", description="Description", deadline=datetime(2021, 3, 13, 0, 0), creator=self.user) db.session.add(todo) db.session.commit()
from flask import Flask, render_template, request, redirect, url_for from flask_sqlalchemy import SQLAlchemy import os from kanban import db, app class Task(db.Model): #A Task table __tablename__ = 'Task' id = db.Column(db.Integer, primary_key=True) #a unique identifier for each task text = db.Column(db.String(100)) #the description of the task category = db.Column(db.String(10)) #to do / doing / done db.create_all() #create the tables @app.route('/') def index(): '''Fetch all tasks from the three categories and pass to index.html''' todo = Task.query.filter_by(category='To Do').all() doing = Task.query.filter_by(category='Doing').all() done = Task.query.filter_by(category='Done').all() return render_template('index.html', todo=todo, doing=doing, done=done) @app.route('/add', methods=['POST']) def add(): '''Fetch get a new task from the form, add it to the db, return to index page''' newtask = Task(text=request.form['text'], category=request.form['category'])
from kanban import app, db db.create_all() if __name__ == '__main__': app.config['SESSION_TYPE'] = 'filesystem' app.run(debug=True)