Exemplo n.º 1
0
    def setup(self):

        # get app test config
        app = create_app('www.settings.TestConfig', env='dev')

        # create test app
        self.app = app.test_client()
    def test_dev_config(self):
        """ Tests if the development config loads correctly """

        app = create_app('www.settings.DevConfig')

        assert app.config['DEBUG'] is True
        assert app.config['CACHE_TYPE'] == 'null'
Exemplo n.º 3
0
 def setUp(self):
     self.app = create_app(_config=TestConfig)
     self.app.config['TESTING'] = True
     self.client = self.app.test_client()
     self.ID = "ID"
     self.MESSAGE_WRONG = "You may have landed on the wrong page."
     self.MESSAGE_INELIGIBLE = "Thank you for participating!"
     self.MESSAGE_HOMEPAGE = "<title>MathBot - Ada</title>"
     self.MESSAGE_FINISHED = "Thank you for completing the study!"
     self.MESSAGE_VIDEO = "https://www.youtube.com/iframe_api"
     self.MESSAGE_MATHBOT = "<title>MathBot - Ada</title>"
    def test_prod_config(self):
        """ Tests if the production config loads correctly """

        app = create_app('www.settings.ProdConfig')

        assert app.config['CACHE_TYPE'] == 'simple'
Exemplo n.º 5
0
from www import create_app

app = create_app()
# gunicorn run:app -c gunicorn_conf.py



Exemplo n.º 6
0
#!/usr/bin/env python

import os

from flask.ext.script import Manager, Server
from flask.ext.script.commands import ShowUrls, Clean
from www import create_app
from www.extensions import mongo

# default to dev config because no one should use this in
# production anyway
env = os.environ.get('WWW_ENV', 'dev')
app = create_app('www.settings.%sConfig' % env.capitalize())

manager = Manager(app)
manager.add_command("server", Server())
manager.add_command("show-urls", ShowUrls())
manager.add_command("clean", Clean())


@manager.shell
def make_shell_context():
  """ Creates a python REPL with several default imports
      in the context of the app
  """

  return dict(app=app, mongo=mongo)

@manager.command
def create_db():
  if env == 'dev':
Exemplo n.º 7
0
def testapp(request):
    app = create_app('www.settings.TestConfig')
    client = app.test_client()
    return client
Exemplo n.º 8
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

__author__ = 'hipponensis'

import os

from www import create_app, db

from www.models import User, Question, Answer, Tag, Collection, Comment, Message

app = create_app(os.getenv('FLASK_CONFIG') or 'default')

def test():
    '''
    单元测试
    '''
    import unittest
    tests = unittest.TestLoader().discover('tests')
    unittest.TextTestRunner(verbosity=2).run(tests)

if __name__ == '__main__':
    app.run(debug=True)

Exemplo n.º 9
0
 def setUp(self):
     self.app = create_app('testing')
     self.app_context = self.app.app_context()
     self.app_context.push()
     db.create_all()