aboutsummaryrefslogtreecommitdiff
path: root/budget/web.py
diff options
context:
space:
mode:
authorAlexis Metaireau <alexis@notmyidea.org>2011-08-21 20:54:20 +0200
committerAlexis Metaireau <alexis@notmyidea.org>2011-08-21 20:54:20 +0200
commit35ea308a2692365001dc88212999df9a041bdaf7 (patch)
treec519797a3d7added2421840e78f56e488096b856 /budget/web.py
parent63a64910018cbc029e34ccf93370649a517c96d8 (diff)
downloadihatemoney-mirror-35ea308a2692365001dc88212999df9a041bdaf7.zip
ihatemoney-mirror-35ea308a2692365001dc88212999df9a041bdaf7.tar.gz
ihatemoney-mirror-35ea308a2692365001dc88212999df9a041bdaf7.tar.bz2
Fix a weird behavior with tests and databases.
Now all the database during the tests is in memory, created for each test and cleared at the end of the test.
Diffstat (limited to 'budget/web.py')
-rw-r--r--budget/web.py22
1 files changed, 13 insertions, 9 deletions
diff --git a/budget/web.py b/budget/web.py
index 4e2b33f..59d7f30 100644
--- a/budget/web.py
+++ b/budget/web.py
@@ -14,15 +14,6 @@ app = Flask(__name__)
app.config.from_object("default_settings")
mail = Mail()
-# db
-db.init_app(app)
-db.app = app
-db.create_all()
-
-# mail
-mail.init_app(app)
-
-
@app.url_defaults
def add_project_id(endpoint, values):
if 'project_id' in values or not hasattr(g, 'project'):
@@ -126,6 +117,11 @@ def exit():
@app.route("/demo")
def demo():
project = Project.query.get("demo")
+ if not project:
+ project = Project(id="demo", name=u"demonstration", password="demo",
+ contact_email="demo@notmyidea.org")
+ db.session.add(project)
+ db.session.commit()
session[project.id] = project.password
return redirect(url_for("list_bills", project_id=project.id))
@@ -247,6 +243,14 @@ def reset_bills():
def main():
+ # db
+ db.init_app(app)
+ db.app = app
+ db.create_all()
+
+ # mail
+ mail.init_app(app)
+
app.run(host="0.0.0.0", debug=True)
if __name__ == '__main__':