Make the app config more powerful in terms of injecting fake dependencies. Refactor the tests to use metaclasses and to actually all run.
This commit is contained in:
parent
2a849f631b
commit
2cd98fc58e
15 changed files with 669 additions and 511 deletions
10
app.py
10
app.py
|
@ -7,7 +7,8 @@ from flask.ext.principal import Principal
|
|||
from flask.ext.login import LoginManager
|
||||
from flask.ext.mail import Mail
|
||||
|
||||
from config import ProductionConfig, DebugConfig, LocalHostedConfig
|
||||
from config import (ProductionConfig, DebugConfig, LocalHostedConfig,
|
||||
TestConfig)
|
||||
from util import analytics
|
||||
|
||||
|
||||
|
@ -22,6 +23,9 @@ if stack.startswith('prod'):
|
|||
elif stack.startswith('localhosted'):
|
||||
logger.info('Running with debug config on production data.')
|
||||
config = LocalHostedConfig()
|
||||
elif stack.startswith('test'):
|
||||
logger.info('Running with test config on ephemeral data.')
|
||||
config = TestConfig()
|
||||
else:
|
||||
logger.info('Running with debug config.')
|
||||
config = DebugConfig()
|
||||
|
@ -36,6 +40,6 @@ login_manager.init_app(app)
|
|||
mail = Mail()
|
||||
mail.init_app(app)
|
||||
|
||||
stripe.api_key = app.config['STRIPE_SECRET_KEY']
|
||||
stripe.api_key = app.config.get('STRIPE_SECRET_KEY', None)
|
||||
|
||||
mixpanel = analytics.init_app(app)
|
||||
mixpanel = app.config['ANALYTICS'].init_app(app)
|
||||
|
|
Reference in a new issue