Skip to content
This repository has been archived by the owner on May 16, 2020. It is now read-only.

Make init_for call implicit. #6

Merged
merged 2 commits into from
May 4, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ install:
- pip install -r test_requirements.txt
- pip install -r requirements.txt
script:
- nosetests -v tests
- nohup python runtestserver.py &
- FLASK_ENV=testing nosetests -v tests
- FLASK_ENV=testing nohup python runtestserver.py &
- sleep 10
addons:
postgresql: "9.4"
Expand Down
23 changes: 11 additions & 12 deletions outreach/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,18 @@ def init_flask_admin():


# Configure the app
def init_for(env):
coaster.app.init_app(app, env)
db.init_app(app)
db.app = app
coaster.app.init_app(app)
db.init_app(app)
db.app = app

RQ(app)
RQ(app)

lastuser.init_app(app)
lastuser.init_usermanager(UserManager(db, User))
app.config['tz'] = timezone(app.config['TIMEZONE'])
baseframe.init_app(app, requires=['outreach'], ext_requires=['baseframe-bs3', 'fontawesome>=4.0.0', 'ractive', 'ractive-transitions-fly', 'validate', 'nprogress', 'baseframe-footable'])
lastuser.init_app(app)
lastuser.init_usermanager(UserManager(db, User))
app.config['tz'] = timezone(app.config['TIMEZONE'])
baseframe.init_app(app, requires=['outreach'], ext_requires=['baseframe-bs3', 'fontawesome>=4.0.0', 'ractive', 'ractive-transitions-fly', 'validate', 'nprogress', 'baseframe-footable'])

mail.init_app(app)
wtforms_json.init()
mail.init_app(app)
wtforms_json.init()

init_flask_admin()
init_flask_admin()
2 changes: 1 addition & 1 deletion rq.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash

rqworker -c rqdev outreach
rqworker -c rqinit outreach
16 changes: 0 additions & 16 deletions rqdev.py

This file was deleted.

3 changes: 1 addition & 2 deletions rqinit.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from urlparse import urlparse

from outreach import init_for, app
from outreach import app

init_for('prod')
REDIS_URL = app.config.get('REDIS_URL', 'redis://localhost:6379/0')

# REDIS_URL is not taken by setup_default_arguments function of rq/scripts/__init__.py
Expand Down
3 changes: 1 addition & 2 deletions runserver.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python
from outreach import app, init_for
from outreach import app
from outreach.models import *
init_for('dev')
app.run('0.0.0.0', debug=True, port=4000)
3 changes: 3 additions & 0 deletions runtests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
export FLASK_ENV="TESTING"
coverage run `nosetests -v tests`
3 changes: 1 addition & 2 deletions tests/test_kharcha.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import json
import unittest
from flask import url_for
from outreach import app, init_for
from outreach import app
from outreach.models import (db, SaleItem)
from fixtures import init_data

Expand All @@ -11,7 +11,6 @@ class TestKharchaAPI(unittest.TestCase):
def setUp(self):
self.ctx = app.test_request_context()
self.ctx.push()
init_for('test')
db.drop_all()
db.create_all()
init_data()
Expand Down
3 changes: 1 addition & 2 deletions tests/test_order.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import unittest
import json
from outreach import app, init_for
from outreach import app
from outreach.models import *
from fixtures import init_data

Expand All @@ -10,7 +10,6 @@ class TestOrder(unittest.TestCase):
def setUp(self):
self.ctx = app.test_request_context()
self.ctx.push()
init_for('test')
db.create_all()
init_data()
self.client = app.test_client()
Expand Down
3 changes: 1 addition & 2 deletions website.wsgi
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import sys
import os.path
sys.path.insert(0, os.path.dirname(__file__))
from outreach import app as application, init_for
init_for('production')
from outreach import app as application