コード例 #1
0
ファイル: conftest.py プロジェクト: kubaodias/prayerbot
def app():
    os.environ["ACCESS_TOKEN"] = "1"
    import web
    app = web.create_app(sqlite_path='sqlite:///test_intent.db')
    #app = create_app()
    import dbms.create_db
    return app
コード例 #2
0
def test_add():
    app = create_app()
    c = app.test_client()

    a = 3
    b = 7
    res = c.get("_calculate", query_string=qstr(a, '+', b))
    assert res.status_code == 200
    assert extr(res) == a + b

    a = 123341
    b = 48314271
    res = c.get("_calculate", query_string=qstr(a, '+', b))
    assert res.status_code == 200
    assert extr(res) == a + b

    a = -8237183
    b = 1231
    res = c.get("_calculate", query_string=qstr(a, '+', b))
    assert res.status_code == 200
    assert extr(res) == a + b

    a = 231.3214
    b = -65435.532
    res = c.get("_calculate", query_string=qstr(a, '+', b))
    assert res.status_code == 200
    assert extr(res) == a + b

    a = 312.32
    b = 71421.512
    res = c.get("_calculate", query_string=qstr(a, '+', b))
    assert res.status_code == 200
    assert extr(res) == a + b
コード例 #3
0
ファイル: conftest.py プロジェクト: kubaodias/prayerbot
def app():
    os.environ["ACCESS_TOKEN"] = "1"
    import web
    app = web.create_app(sqlite_path='sqlite:///test_intent.db')
    #app = create_app()
    import dbms.create_db
    return app
コード例 #4
0
def test_mul():
    app = create_app()
    c = app.test_client()

    a = 3
    b = 7
    res = c.get("_calculate", query_string=qstr(a, '*', b))
    assert res.status_code == 200
    assert extr(res) == a * b

    a = -123
    b = -4871
    res = c.get("_calculate", query_string=qstr(a, '*', b))
    assert res.status_code == 200
    assert extr(res) == a * b

    a = -883
    b = 1281
    res = c.get("_calculate", query_string=qstr(a, '*', b))
    assert res.status_code == 200
    assert extr(res) == a * b

    a = 231.3214
    b = -6435.532
    res = c.get("_calculate", query_string=qstr(a, '*', b))
    assert res.status_code == 200
    assert extr(res) == a * b

    a = 312.32
    b = 71421.512
    res = c.get("_calculate", query_string=qstr(a, '*', b))
    assert res.status_code == 200
    assert extr(res) == a * b
コード例 #5
0
 def setUp(self):
     self.app = create_app('testing')
     self.app.app_context().push()
     self.client = self.app.test_client()
     self.first_request = {
         'title': 'First Request',
         'description': 'First Description',
         'clientId': 1,
         'priority': 1,
         'productId': 1,
         'targetDate': 'May 30, 2019'
     }
     self.second_request = {
         'title': 'Second Request',
         'description': 'Second Description',
         'clientId': 1,
         'priority': 1,
         'productId': 1,
         'targetDate': 'May 30, 2019'
     }
     self.request_edit = {
         'title': 'First Request Edited',
         'description': 'First Description Edited',
         'clientId': 1,
         'priority': 1,
         'productId': 1,
         'targetDate': 'May 30, 2019'
     }
コード例 #6
0
    def test_prod_config(self):
        """ Tests if the production config loads correctly """

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

        assert app.config['SQLALCHEMY_DATABASE_URI'] == 'sqlite:///../database.db'
        assert app.config['CACHE_TYPE'] == 'simple'
コード例 #7
0
    def test_test_config(self):
        """ Tests if the test config loads correctly """

        app = create_app('web.settings.TestConfig')

        assert app.config['DEBUG'] is True
        assert app.config['SQLALCHEMY_ECHO'] is True
        assert app.config['CACHE_TYPE'] == 'null'
コード例 #8
0
ファイル: conftest.py プロジェクト: harukkkk/web-cw2
def test_client():
    print('kkk- init')
    app = create_app('test')
    os.environ.setdefault('FLASK_ENV', 'test')

    with app.test_client() as testing_client:
        with app.app_context():
            yield testing_client
コード例 #9
0
ファイル: tests.py プロジェクト: jeffroche/dropcms
 def setUp(self):
     self.patch1 = mock.patch('dropbox.client.DropboxClient.metadata',
                              side_effect=metadata_side_effects)
     self.patch2 = mock.patch('dropbox.client.DropboxClient.get_file')
     self.patched_metadata = self.patch1.start()
     self.patched_get_file = self.patch2.start()
     app = web.create_app('test_settings.py')
     self.app = app.test_client()
コード例 #10
0
    def test_test_config(self):
        """ Tests if the test config loads correctly """

        app = create_app('web.settings.TestConfig')

        assert app.config['DEBUG'] is True
        assert app.config['SQLALCHEMY_ECHO'] is True
        assert app.config['CACHE_TYPE'] == 'null'
コード例 #11
0
ファイル: test_views.py プロジェクト: netor27/messages-api
 def setUp(self):
     self.app = create_app('configtest')
     self.test_client = self.app.test_client()
     self.app_context = self.app.app_context()
     self.app_context.push()
     self.test_user_name = 'testuser'
     self.test_user_password = '******'
     db.create_all()
コード例 #12
0
    def test_prod_config(self):
        """ Tests if the production config loads correctly """

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

        assert app.config[
            'SQLALCHEMY_DATABASE_URI'] == 'sqlite:///../database.db'
        assert app.config['CACHE_TYPE'] == 'simple'
コード例 #13
0
def app():
    app = create_app('testing')

    with app.app_context():
        execute_sql(_create_sql)
        execute_sql(_data_sql)

        yield app
コード例 #14
0
ファイル: api_test.py プロジェクト: 201560543/zappo
 def create_app(self):
     app = create_app(base)
     app.config['TESTING'] = True
     # Default port is 5000
     app.config['LIVESERVER_PORT'] = 8943
     # Default timeout is 5 seconds
     app.config['LIVESERVER_TIMEOUT'] = 10
     return app
コード例 #15
0
    def test_dev_config(self):
        """ Tests if the development config loads correctly """

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

        assert app.config['DEBUG'] is True
        assert app.config['SQLALCHEMY_DATABASE_URI'] == 'sqlite:///../database.db'
        assert app.config['CACHE_TYPE'] == 'null'
コード例 #16
0
ファイル: tests.py プロジェクト: jeffroche/dropcms
 def setUp(self):
     self.patch1 = mock.patch('dropbox.client.DropboxClient.metadata',
                              side_effect=metadata_side_effects)
     self.patch2 = mock.patch('dropbox.client.DropboxClient.get_file')
     self.patched_metadata = self.patch1.start()
     self.patched_get_file = self.patch2.start()
     app = web.create_app('test_settings.py')
     self.app = app.test_client()
コード例 #17
0
def client():
    app = create_app('test')
    app.config.from_object('web.config.TestingConfig')
    client = app.test_client()
    ctx = app.app_context()
    ctx.push()
    yield client  # this is where the testing happens!
    ctx.pop()
コード例 #18
0
    def test_dev_config(self):
        """ Tests if the development config loads correctly """

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

        assert app.config['DEBUG'] is True
        assert app.config[
            'SQLALCHEMY_DATABASE_URI'] == 'sqlite:///../database.db'
        assert app.config['CACHE_TYPE'] == 'null'
コード例 #19
0
ファイル: conftest.py プロジェクト: zhantanfeng/KunshanSystem
def init_test_app():
    app = create_app('testing')
    context = app.test_request_context()
    context.push()
    client = app.test_client()
    runner = app.test_cli_runner()
    # TODO: 暂时只返回client pytest再次调用以清除环境
    yield client
    context.pop()
コード例 #20
0
def app():
    """Base app fixture for flask app testing.

    Returns:
        flask test app.
    """
    app_ = create_app()
    app_.debug = True
    app_.testing = True
    app_.config["SERVER_NAME"] = "localhost"
    return app_
コード例 #21
0
 def make_DBLog(subject, event, badge, detail=''):
     """ wrapper method to call DBLog.new() on alarm event """
     app = create_app()
     with app.app_context():
         DBLog.new(subject=subject,
                   scope="ext",
                   badge=badge,
                   message=event,
                   ip='-',
                   user='******',
                   detail=detail)
コード例 #22
0
def app():
    app = create_app('test')
    app.config.from_object('web.config.TestingConfig')
    with app.app_context():
        # Initialize the db tables
        db.create_all()
        yield app
        # Remove only the users crated here. Dummy users will be left intact
        User.query.filter(User.email == "*****@*****.**").delete()
        db.session.commit()

    return app
コード例 #23
0
ファイル: __init__.py プロジェクト: suminb/web
def testapp(request):
    """Session-wide test `Flask` application."""
    settings_override = {"TESTING": True, "DEBUG": True}
    app = create_app(__name__, config=settings_override, template_folder="../templates")

    # Establish an application context before running the tests.
    ctx = app.app_context()
    ctx.push()

    def teardown():
        ctx.pop()

    request.addfinalizer(teardown)
    return app.test_client()
コード例 #24
0
def env():
    # start server
    os.environ["KFCHESS_CONFIG"] = os.path.join(os.path.dirname(__file__), "../config.py")
    app = create_app()
    socketio = SocketIO(app)
    def on_join(room):
        join_room(room, namespace="/game")
    socketio.on_event('join', on_join)

    # start polling thread
    game_resps_q = "resps:{}".format(uuid.uuid4())
    redis_db     = redis.StrictRedis()  #Todo: take redis from some configs
    t = Thread(target=poll_game_cnfs, args=(redis_db, "test_store", game_resps_q, socketio))
    t.daemon = True
    t.start()
    yield Env(app=app, socketio=socketio, q=game_resps_q, db=redis_db)
コード例 #25
0
ファイル: freeze.py プロジェクト: jeffroche/dropcms
def build(config_overrides):
    app = create_app(config_overrides)
    app.config['FREEZER_REMOVE_EXTRA_FILES'] = True
    freezer = Freezer(app)

    @freezer.register_generator
    def page_url_generator():
        cms = get_or_create_cms()
        contents = cms.structure()
        folder_names = contents['folders'].keys()
        for folder in folder_names:
            yield 'page_router.folder_index', {'folder_name': folder}
            page_names = contents['folders'][folder]['pages'].keys()
            for page in page_names:
                yield 'page_router.render_page', {'folder_name': folder,
                                                  'page_name': page}

    freezer.freeze()
コード例 #26
0
ファイル: conftest.py プロジェクト: sjroh/web
def testapp(request):
    """Session-wide test `Flask` application."""
    settings_override = {
        'TESTING': True,
        'DEBUG': True,
    }
    app = create_app(__name__,
                     config=settings_override,
                     template_folder='../templates')

    # Establish an application context before running the tests.
    ctx = app.app_context()
    ctx.push()

    def teardown():
        ctx.pop()

    request.addfinalizer(teardown)
    return app.test_client()
コード例 #27
0
def testapp(request):
    app = create_app('web.settings.TestConfig')
    client = app.test_client()

    db.app = app
    db.create_all()

    if getattr(request.module, "create_user", True):
        admin = User('admin', 'supersafepassword')
        db.session.add(admin)
        db.session.commit()

    def teardown():
        db.session.remove()
        db.drop_all()

    request.addfinalizer(teardown)

    return client
コード例 #28
0
def build(config_overrides):
    app = create_app(config_overrides)
    app.config['FREEZER_REMOVE_EXTRA_FILES'] = True
    freezer = Freezer(app)

    @freezer.register_generator
    def page_url_generator():
        cms = get_or_create_cms()
        contents = cms.structure()
        folder_names = contents['folders'].keys()
        for folder in folder_names:
            yield 'page_router.folder_index', {'folder_name': folder}
            page_names = contents['folders'][folder]['pages'].keys()
            for page in page_names:
                yield 'page_router.render_page', {
                    'folder_name': folder,
                    'page_name': page
                }

    freezer.freeze()
コード例 #29
0
def make_service(reactor=None):

    if reactor is None:
        from twisted.internet import reactor

    # create root service
    root = service.MultiService()

    # MQTT
    mqttFactory = MQTTFactory(profile=MQTTFactory.PUBLISHER)
    mqttEndpoint = clientFromString(reactor, settings.MQTT_BROKER_URI)
    mqttService = MQTTService(mqttEndpoint, mqttFactory)
    mqttService.setServiceParent(root)

    # create a Twisted Web resource for our WebSocket server
    wsFactory = SerialToWebsocketServerFactory(settings.WS_URI)
    wsResource = WebSocketResource(wsFactory)

    # create a Twisted Web WSGI resource for our Flask server
    wsgiResource = WSGIResource(reactor, reactor.getThreadPool(), create_app())

    # create a root resource serving everything via WSGI/Flask, but
    # the path "/ws" served by our WebSocket stuff
    rootResource = WSGIRootResource(wsgiResource,
                                    {settings.WS_PATH: wsResource})

    # create a Twisted Web Site
    site = Site(rootResource)

    # create service and add it to root
    wsService = strports.service(settings.SERVICE_URI, site)
    wsService.setName('web')
    wsService.setServiceParent(root)

    # serial port monitor
    SerialPort(SerialProtocol(wsFactory, mqttService),
               settings.SERIAL_PORT,
               reactor,
               baudrate=settings.SERIAL_BAUDRATE)

    return root
コード例 #30
0
                    help='Port to use in debug mode.',
                    default=16000,
                    type=int,
                    required=False)
parser.add_argument('-r','--rules',
                    help='List registered rules.',
                    action="store_true",
                    default=False,
                    required=False)

args = parser.parse_args()

# Create app instance
from web import create_app

app = create_app(debug=args.debug)


if args.rules:
    for rule in app.url_map.iter_rules():
        print("Rule: {0} calls {1} ({2})".format(rule, rule.endpoint, ",".join(rule.methods)))

if __name__ == "__main__":
    '''
    This is called when this script is directly run.
    uWSGI gets the "app" object (the "callable") and runs it itself.
    '''
    
    # Add NLTK_DATA variable so data files can be loaded
    os.environ['NLTK_DATA'] = os.path.dirname(os.path.realpath(__file__)) + '/web/utils/nltk_data/'
    
コード例 #31
0
ファイル: wsgi.py プロジェクト: Zizhou/igg
from web import create_app
from settings import app_config

igg = create_app(app_config)
コード例 #32
0
ファイル: test_setting.py プロジェクト: cantis/CoinPurse
def app():
    ''' Set test App context '''
    app = create_app()
    config = TestConfig()
    app.config.from_object(config)
    return app
コード例 #33
0
ファイル: wsgi.py プロジェクト: danielmichaels/databank
import os

from web import create_app

app = create_app(os.environ.get("FLASK_ENV") or 'default')

if __name__ == "__main__":
    app.run()
コード例 #34
0
ファイル: manage.py プロジェクト: mnsbus/flask-sketch
from web import create_app
from flask.ext.script import Manager, Server

app = create_app('local')
manager = Manager(app)

manager.add_command("runserver", Server(
	use_debugger = True,
	use_reloader = True,
	host = '0.0.0.0',
	port=5000)
)

if __name__ == '__main__':
	manager.run()
コード例 #35
0
from web import create_app

app = create_app('flask-dev.cfg')
コード例 #36
0
ファイル: run.py プロジェクト: zkhan93/dobby
import web

app = web.create_app()

if __name__ == "__main__":
    app.run(host="0.0.0.0", port=5000, debug=True)
コード例 #37
0
from web import db, create_app
from models.data_models import Account, Pack, Transaction, Coach, Tournament

app = create_app()
app.app_context().push()

for coach in Coach.query.with_deleted().all():
    db.session.delete(coach)

for tourn in Tournament.query.all():
    db.session.delete(tourn)

db.session.commit()
コード例 #38
0
ファイル: run.py プロジェクト: suminb/web
import os

from web import create_app


if __name__ == '__main__':
    host = os.environ.get('HOST', '0.0.0.0')
    port = int(os.environ.get('PORT', 8024))
    debug = bool(os.environ.get('DEBUG', 0))

    app = create_app(config={'DEBUG': debug})
    app.run(host=host, port=port)

    if app.config['DEBUG']:
        from werkzeug import SharedDataMiddleware
        import os
        app.wsgi_app = SharedDataMiddleware(app.wsgi_app, {
            '/': os.path.join(os.path.dirname(__file__), 'static')
        })
コード例 #39
0
ファイル: __main__.py プロジェクト: suminb/web
def build():
    """Builds static web pages."""
    app = create_app()
    with app.app_context():
        freezer = Freezer(app)
        freezer.freeze()
コード例 #40
0
ファイル: run.py プロジェクト: icodeface/x.codeface.cn
#!/usr/bin/env python
# __author__ CodeFace
from web import create_app

app = create_app('config')

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

コード例 #41
0
ファイル: __init__.py プロジェクト: nezaj/mongoose
 def setUp(self):
     self.app = create_app(TestConfig)
     self.client = self.app.test_client()
コード例 #42
0
 def setUp(self):
     self.app = create_app()
     self.client = self.app.test_client()
コード例 #43
0
ファイル: manage.py プロジェクト: hoytnix/spidey
from werkzeug.utils import import_string
from sqlalchemy.exc import (IntegrityError, OperationalError)
from flask_script import (Manager, Shell, Server, prompt, prompt_pass,
                          prompt_bool)
from flask_migrate import (MigrateCommand, upgrade)

from web import create_app
from web.extensions import db

# Use the development configuration if available
try:
    from web.configs.development import DevelopmentConfig as Config
except ImportError:
    from web.configs.default import DefaultConfig as Config

app = create_app(Config)
manager = Manager(app)

# Used to get the plugin translations
#PLUGINS_FOLDER = os.path.join(app.root_path, "plugins")

# Run local server
manager.add_command("runserver", Server("0.0.0.0", port=53476, 
    use_debugger=True, 
    use_reloader=True))

# Migration commands
manager.add_command('db', MigrateCommand)


# Add interactive project shell
コード例 #44
0
ファイル: __init__.py プロジェクト: nezaj/mongoose
 def setUp(self):
     self.app = create_app(TestConfig)
     self.db = db
     self.db.create_all()
コード例 #45
0
def app():
    app = create_app()
    config = TestConfig()
    app.config.from_object(config)
    return app
コード例 #46
0
ファイル: manage.py プロジェクト: leozhao0709/fsc
from flask_migrate import Migrate, MigrateCommand
from flask_script import Manager, Shell
from web.models import stocks
from web import create_app, db
from command.crawl import Crawl

__author__ = 'lzhao'
__date__ = '5/14/16'
__time__ = '5:21 PM'

logging.basicConfig(filename=None, level=logging.DEBUG, format="%(asctime)s - %(levelname)s - %(message)s")

# logging.disable(logging.CRITICAL)

app = create_app('default')
manager = Manager(app)
migrate = Migrate(app, db)


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


manager.add_command("shell", Shell(make_context=make_shell_context))
manager.add_command('db', MigrateCommand)
manager.add_command('crawl', Crawl())

if __name__ == '__main__':
	manager.run()
コード例 #47
0
from web import create_app, db
from web.config import base

app = create_app(base)

if __name__ == '__main__':
    with app.app_context():
        app.run(debug=True, host='0.0.0.0')

コード例 #48
0
ファイル: run.py プロジェクト: jeffroche/dropcms
from web import create_app

if __name__ == "__main__":
    app = create_app()
    app.debug = True
    app.run()
コード例 #49
0
ファイル: wsgi.py プロジェクト: cantis/CoinPurse
from web import create_app, clear_filters

application = create_app()

clear_filters()

if __name__ == '__main__':
    application.run()
コード例 #50
0
ファイル: run.py プロジェクト: hugoantunes/shortURL
# encoding: utf-8
import os
import sys

LOCAL_PATH = os.path.abspath(os.path.dirname(__file__))
os.path.abspath(os.path.join(LOCAL_PATH, '../'))

sys.path.insert(0, os.path.abspath(os.path.join(LOCAL_PATH, '../')))

import settings

from web import create_app

app = create_app(settings)

if __name__ == "__main__":
    app.run(port=8000, host='0.0.0.0')
コード例 #51
0
ファイル: main.py プロジェクト: ranisalt/cagr-api
import argparse
import asyncio
import hub
import web


parser = argparse.ArgumentParser()
parser.add_argument('-p', '--port', type=int)
args = parser.parse_args()

app = web.create_app()
web.run_app(app, port=args.port)
コード例 #52
0
#!/usr/bin/env python

import os

from flask.ext.script import Manager, Server
from flask.ext.migrate import Migrate, MigrateCommand
from flask.ext.script.commands import ShowUrls, Clean
from web import create_app
from web.models import db, User

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

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

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

    return dict(app=app, db=db, User=User)