コード例 #1
0
    def setUp(self):
        self.market_app = create_application()

        self.db_fd, self.market_app.config['DATABASE'] = tempfile.mkstemp()
        self.market_app.config['TESTING'] = True
        with self.market_app.app_context():
            init_database()

        self.client = self.market_app.test_client()
コード例 #2
0
    def setUp(self):
        self.instance_directory = tempfile.mkdtemp()
        config_file = os.path.join(self.instance_directory, 'application.cfg')
        with open(config_file, 'w') as fh:
            fh.write("INSTRUMENT = 'test_instrument'")

        self.market_app = create_application(self.instance_directory)
        self.market_app.testing = True

        self.db_fd, self.market_app.config['DATABASE'] = tempfile.mkstemp()
        self.market_app.config['TESTING'] = True
        self.app = self.market_app.test_client()
        with self.market_app.app_context():
            init_database()
コード例 #3
0
def generate_swagger(fp):
    """Initialize an instance of the application API, then use its
    context to generate a json schema and dump to disk as 'swagger.json'
    """
    print('Generating swagger.json file')
    app = create_application()
    api = get_api()

    # Required to make sure the app is able to create a URL adapter for
    # request independent URL generation. Otherwise a RuntimeError is
    # raised
    app.config['SERVER_NAME'] = 'localhost'
    with app.app_context():
        with open(fp, 'wb') as fh:
            json.dump(api.__schema__, fh)
コード例 #4
0
''' Entry point to start the Potato Market web application

To start the web application::

    python run.py

'''
import os

from market_app.application import create_application
from market_app.database import init_database


def init_db(application):
    """ Initialize the store database with some orders. """

    with application.app_context():
        if not os.path.exists(application.instance_path):
            os.makedirs(application.instance_path)
        init_database()

if __name__ == '__main__':
    app = create_application()

    init_db(app)
    app.run(debug=True)
コード例 #5
0
''' Entry point to start the Potato Market web application

To start the web application::

    python run_potato.py

'''

import os

from market_app.application import create_application
from market_app.database import init_database


def init_db(application):
    """ Initialize the store database with some orders. """

    with application.app_context():
        if not os.path.exists(application.instance_path):
            os.makedirs(application.instance_path)
        init_database()


if __name__ == '__main__':

    app = create_application(os.path.abspath('potato_instance'))

    init_db(app)
    app.run(debug=True)
コード例 #6
0
ファイル: run_carrot.py プロジェクト: fenwk0/TraderStore
''' Entry point to start the Carrot Market web application

To start the web application::

    python run_carrot.py

'''

import os

from market_app.application import create_application
from market_app.database import init_database


def init_db(application):
    """ Initialize the store database with some orders. """

    with application.app_context():
        if not os.path.exists(application.instance_path):
            os.makedirs(application.instance_path)
        init_database()


if __name__ == '__main__':

    app = create_application(os.path.abspath('carrot_instance'))

    init_db(app)
    app.run(debug=True)