Exemplo n.º 1
0
def test_app():
    app = create_app()
    app.config.from_object('web.settings.TestingConfig')
    with app.app_context():
        yield app
Exemplo n.º 2
0
 def setUp(self):
     self.app = create_app()
     self.test_client = self.app.test_client()
Exemplo n.º 3
0
import os
import glob
import unittest

from web.app import create_app
from web.utils import get_data_file

app = create_app()


class TestSyntax(unittest.TestCase):

    def setUp(self):
        self.app = create_app()
        self.test_client = self.app.test_client()

    def test_data_files(self):
        data_files = []
        data_files += glob.glob(os.path.join(self.app.config['APP_PATH'],
                                             'data', '*.json'))
        data_files += glob.glob(os.path.join(self.app.config['APP_PATH'],
                                             'data', '*.yml'))

        for data_file in data_files:
            with self.app.app_context():
                self.assertTrue(get_data_file(os.path.basename(data_file)))

    def test_sponsors_yml_file(self):
        with self.app.app_context():
            sponsors = get_data_file('sponsors.yml')
Exemplo n.º 4
0
def client(loop, aiohttp_client):
    return loop.run_until_complete(aiohttp_client(create_app()))
Exemplo n.º 5
0
from web.app import create_app

app = create_app('development')
Exemplo n.º 6
0
import json
import os
import pytest
from unittest import mock

from web.app import create_app

os.environ['SECRET_KEY'] = 'top secret!'
os.environ['DATABASE_URL'] = 'postgres:///lds-callings-test'
create_app()

# Add views to the app after creating it...
import web.views

# http://flask.pocoo.org/docs/0.12/testing/


class JSONFriendlyClient:
    """Wrapper around the Flask test client providing easier JSON support."""
    def __init__(self, flask_test_client):
        self._client = flask_test_client

    def post(self, *args, **kwargs):
        json_data = kwargs.pop('json', None)
        if json_data:
            kwargs['data'] = json.dumps(json_data)
            kwargs['content_type'] = 'application/json'
        return self._client.post(*args, **kwargs)

    def __getattr__(self, item):
        return getattr(self._client, item)
Exemplo n.º 7
0
import os

from web.app import create_app

app = create_app(config=os.environ["CONFIG"])

if __name__ == "__main__":
    app.run(host="0.0.0.0", port=5000)
Exemplo n.º 8
0
# -*- coding: utf-8 -*-
"""Create an application instance."""
from web.app import create_app
from web.config import Config

app = create_app(Config)
Exemplo n.º 9
0
def test_app(loop, aiohttp_client):
    """App  fixture."""
    app = create_app(test=True)
    return loop.run_until_complete(aiohttp_client(app))
Exemplo n.º 10
0
# -*- coding: utf-8 -*-
import logging
from web.app import create_app

from web.event.models import Event
from web.firm.models import Firm
from web.person.models import Person, PersonEvent
from web.user.models import User
from web.term.models import Term

try:
    from web.settings_local import Config
except Exception as e:
    logging.exception("Exception: %(body)s", {'body': e})
    from web.settings import Config

app = create_app(Config)
Exemplo n.º 11
0
import os
from flask_script import Manager
from flask_migrate import Migrate, MigrateCommand

from web.app import create_app, db, UserModel, RoomModel
from web.server import Server

env_name = os.getenv('FLASK_ENV')
app = create_app(env_name)

migrate = Migrate(app, db)

manager = Manager(app)

manager.add_command("runserver", Server())

manager.add_command('db', MigrateCommand)


# define the command for creating db
@manager.command
def create_db(db_first=False):
    if db_first == False:
        db.drop_all()
    db.create_all()
    db.session.commit()


# define the command for inserting sample data for test.
@manager.command
def seed_db():
Exemplo n.º 12
0
from web.app import create_app
from dobot.utils import detect_dobot_port, dobot_is_on_port

DEFAULT_BAUDRATE = 115200

parser = argparse.ArgumentParser(description='Run Dobot WebAPI.')
parser.add_argument('--port', type=int, default=18001)
parser.add_argument('--host', type=str, default='0.0.0.0')
parser.add_argument('--dobot-port', type=str, default=None)
parser.add_argument('--tuner-file', type=str, default='/var/tmp/robot_tuner.dat')
parser.add_argument('--instance_path', type=str, default=None)

args = parser.parse_args()

if not args.dobot_port:
    dobot_port = detect_dobot_port(DEFAULT_BAUDRATE)
    if dobot_port is None:
        print('dobot offline')
        exit(1)
else:
    dobot_port = args.dobot_port
    if not dobot_is_on_port(dobot_port, DEFAULT_BAUDRATE):
        print('dobot is not detected on port {}'.format(dobot_port))
        exit(1)

app = create_app(dobot_port, args.tuner_file, args.instance_path)

if __name__ == '__main__':
    app.run(port=args.port, host=args.host)
Exemplo n.º 13
0
def client():
    flask_app = create_app()
    with flask_app.test_client() as client:
        with flask_app.app_context():
            yield client
Exemplo n.º 14
0
# -*- coding: utf-8 -*-
"""Create an application instance."""
from flask.helpers import get_debug_flag

from web.app import create_app
from web.settings import DevConfig, ProdConfig

#CONFIG = DevConfig if get_debug_flag() else ProdConfig
CONFIG = DevConfig
app = create_app(CONFIG)
Exemplo n.º 15
0
""" Creates an app instance for uwsgi. """
import os

from web.app import create_app

app = create_app(os.getenv("FLASK_CONFIG") or "default")
# coding:utf-8
from __future__ import absolute_import, unicode_literals
from flask_script import Manager, Shell, Server
from web.extension import db, mongo, redis
from web.app import create_app
import datetime
import decimal
import requests

__author__ = "golden"
__date__ = '2017/2/7'
app = create_app('web_config.Developer')
manager = Manager(app)

all_area = ['武侯区', '青羊区', '高新区', '天府新区', '金牛区', '锦江区', '成华区', '双流区', '温江区', '龙泉区', '郫县区', '新都区', '都江堰区', '高新西区', '成都周边']


def make_shell_context():
    return dict(mongo=mongo, app=app)


@manager.option('-d', '--date', dest='date', help=u'统计日期之后', required=False)
@manager.option('-s', '--site', dest='site', help=u'网站', required=False)
def day_increase(date=None, site=None):
    """统计每日新增数据"""
    if not date:
        date = str((datetime.datetime.now() - datetime.timedelta(days=3)).date())
    if site:
        sites = [site]
    else:
        sites = ['fang', 'lianjia', 'anjuke']
Exemplo n.º 17
0
Authors: Turinblueice
Date:
"""
import sys
import os
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))  # 增加默认搜索路径

from flask_script import Manager
from flask_script import Server
from flask_script import Shell
from flask_script import prompt_bool
from web.app.extensions import db
from web import app


manager = Manager(app.create_app('development'))
manager.add_command("runserver", Server('0.0.0.0', port=5050))


def _mk_context():
    return dict(db=db)

manager.add_command("shell", Shell(make_context=_mk_context))  # 为app增加一个内部shell


@manager.command
def createall():
    """
        创建数据库表
    :return:
    """
Exemplo n.º 18
0
# coding:utf-8
from __future__ import absolute_import, unicode_literals
import os

__author__ = "golden"
__date__ = '2017/1/18'

from web.app import create_app

app = create_app(os.environ.get('APP_CONFIG', 'web_config.Developer'))
if __name__ == '__main__':
    app.run(port=5103, debug=True, host='0.0.0.0')
Exemplo n.º 19
0
from web.app import create_app

app = create_app("testing")
app.testing = True
testing_app = app.test_client()
Exemplo n.º 20
0
def runserver():
    port = int(os.environ.get('PORT', 5000))
    app = create_app()
    app.run(debug=True, host='0.0.0.0', port=port)
Exemplo n.º 21
0
from web.app import create_app

app = create_app(config="testing")

if __name__ == "__main__":
    app.run()
Exemplo n.º 22
0
from web.app import create_app

if __name__ == '__main__':
    app = create_app()
    app.run(port=10008)
Exemplo n.º 23
0
def test_dev_config():
    """Development config."""
    app = create_app(DevConfig)
    assert app.config['ENV'] == 'dev'
    assert app.config['DEBUG'] is True
    assert app.config['ASSETS_DEBUG'] is True
Exemplo n.º 24
0
 def setUp(self):
     self.app = create_app()
     self.test_client = self.app.test_client()
Exemplo n.º 25
0
from aiohttp import web

from web.app import create_app

web.run_app(create_app())