Exemple #1
0
    def setUp(self):
        """Define test variables and initialize app."""
        self.app = create_app()
        self.client = self.app.test_client
        self.database_name = "agency_test"
        self.database_path = "postgresql://{}:{}@{}/{}".format(
            'postgres', 'RMGtri2018#', 'localhost:5432', self.database_name)
        setup_db(self.app, self.database_path)

        # binds the app to the current context
        with self.app.app_context():
            self.db = SQLAlchemy()
            self.db.init_app(self.app)
            # create all tables
            self.db.create_all()

        #setup mock data
        movie1 = Movie(title="test102", release="2021-05-12 19:40:01.918917")
        movie2 = Movie(title="test102", release="2021-05-12 19:40:01.918917")
        movie3 = Movie(title="test102", release="2021-05-12 19:40:01.918917")
        movie1.insert()
        movie2.insert()
        movie3.insert()

        artist1 = Actor(name="Ban Jovi", age=24, gender="male")
        artist2 = Actor(name="Ban Jovi", age=24, gender="male")
        artist3 = Actor(name="Ban Jovi", age=24, gender="male")
        artist1.insert()
        artist2.insert()
        artist3.insert()
Exemple #2
0
    def setUp(self):
        self.app = create_app(config_name='testing')
        self.client = self.app.test_client()

        with self.app.app_context():
            print('\n---- Create databases ----\n')
            db.create_all()
Exemple #3
0
def client(loop, aiohttp_client):
    """
    Базовая фикстура для старта приложения и получения aiohttp-клиента
    """
    from src.main import create_app

    app = loop.run_until_complete(create_app())
    return loop.run_until_complete(aiohttp_client(app))
    def setUp(cls):
        cls.app = create_app()
        cls.app_context = cls.app.app_context()
        cls.app_context.push()
        cls.client = cls.app.test_client()

        db.create_all()
        runner = cls.app.test_cli_runner()
        runner.invoke(args=["db-custom", "seed"])
    def setup(self):
        self.testing = True
        self.app = create_app(self.testing, run_app=False)
        self.client = self.app.test_client()
        self.base_uri = 'api/v1/user'

        # Drop all tables, then create
        self.app_name = get_app_name()
        drop_all_main(self.app_name, self.testing)
        createall_main(self.app_name, self.testing)

        self.base_cache = Caches.redis()
Exemple #6
0
    def setup(self):

        testing = True
        self.app = create_app(testing, run_app=False)

        # Drop all tables, then create
        app_name = get_app_name()
        drop_all_main(app_name, testing)
        createall_main(app_name, testing)

        self.store = Stores.user_store()
        self.session = SessionContext.make(app_name, testing)
        self.base_cache = Caches.redis()
Exemple #7
0
    def setUpClass(cls):
        if os.environ.get("FLASK_ENV") != "workflow":
            os.environ["FLASK_ENV"] = "testing"
        else:
            os.environ[
                "DB_TEST_URI"] = "postgresql+psycopg2://postgres:postgres@localhost:5432/poketeams_test"
        cls.app = create_app()
        cls.app_context = cls.app.app_context()
        cls.app_context.push()
        cls.context = cls.app.test_request_context()
        cls.context.push()
        cls.client = cls.app.test_client()

        db.create_all()
        runner = cls.app.test_cli_runner()
        runner.invoke(args=["db-custom", "seed"])
Exemple #8
0
def client():
    app = create_app()
    app.config["TESTING"] = True
    app.config["SECRET_KEY"] = "123456"
    app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///"
    app.config["WTF_CSRF_ANABLED"] = False

    context = app.app_context()
    context.push()
    db.create_all()

    yield app.test_client()

    db.session.remove()
    db.drop_all()
    context.pop()
Exemple #9
0
class BaseTest(TestCase):

    TESTING = True
    BASE_APP = create_app(TestConfig)

    def setUp(self):
        db.init_app(self.app)
        db.create_all()

    def create_app(self):
        self.BASE_APP.config['TESTING'] = True
        # Default port is 5000
        self.BASE_APP.config['LIVESERVER_PORT'] = 8943
        # Default timeout is 5 seconds
        self.BASE_APP.config['LIVESERVER_TIMEOUT'] = 10
        return self.BASE_APP

    def tearDown(self):
        db.session.remove()
        db.drop_all()
Exemple #10
0
def app() -> FastAPI:
    """ test app """
    app = create_app()
    app.include_router(api_v1, prefix=f"{settings.API_VERSION_PREFIX}")
    app.include_router(token_router, prefix="/api/token")
    return app
Exemple #11
0
import argparse

from src.application.common.enums.environment_enum import EnvironmentEnum
from src.main import create_app


def parse_arguments():
    parser = argparse.ArgumentParser(
        description='ToriiServer',
        epilog="And that's how you'd foo a bar",
    )
    parser.add_argument(
        '--environment',
        metavar='environment',
        nargs='?',
        help='Environment to choice',
        dest='environment',
        type=EnvironmentEnum,
        choices=EnvironmentEnum.__members__.values(),
    )

    return parser.parse_args()


if __name__ == '__main__':
    arguments = parse_arguments()
    app = create_app(arguments=arguments)
    app.run()  # debug=True
Exemple #12
0
    def setup(self):

        self.app = create_app(testing=True, run_app=False)
        self.cache = Caches.user_cache()
        self.base_cache = Caches.redis()
def test_create_app():
    app = create_app()
Exemple #14
0
import os
from flask_script import Manager, Shell, Server
from src.main import create_app, db

app = create_app()
manager = Manager(app)


def _make_context():
    """Return context dict for a shell session so you can access
    app and db by default.
    """
    return {'app': app, 'db': db}


manager.add_command('server',
                    Server(host='0.0.0.0', port=os.environ.get('PORT', 9000)))
manager.add_command('shell', Shell(make_context=_make_context))

if __name__ == '__main__':
    manager.run()
Exemple #15
0
def test_client():
    app = create_app()
    return TestClient(app)
Exemple #16
0
import os
from flask_migrate import MigrateCommand
from flask_script import Manager, Shell, Server
from src.main import create_app, db

app = create_app()
manager = Manager(app)


def _make_context():
    """Return context dict for a shell session so you can access
    app and db by default.
    """
    return {'app': app, 'db': db}

manager.add_command('server', Server(port=os.environ.get('PORT', 9000)))
manager.add_command('shell', Shell(make_context=_make_context))
manager.add_command('db', MigrateCommand)


if __name__ == '__main__':
    manager.run()
def app():
    os.environ['APP_ENV'] = 'test'
    app = create_app()
    yield app
Exemple #18
0
"""Create an application instance."""

from flask.helpers import get_debug_flag

from src.main import create_app
from src.settings import DevelopConfig, ProductionConfig

CONFIG = DevelopConfig if get_debug_flag() else ProductionConfig

app = create_app(CONFIG)
Exemple #19
0
import os
from src.main import create_app

app = create_app(os.getenv('CONFIG_MODE') or 'development')

if __name__ == '__main__':
    app.run()
Exemple #20
0
def app_t():
    app_t = create_app()
    yield app_t.test_client()
    del app_t
Exemple #21
0
import os

from src.main import create_app

os.environ['ORCHESTRATE_KEY'] = '1de49651-92d0-4f7c-ae0b-ee92506a55f4'
os.environ['RECAPTCHA_PUBLIC_KEY'] = '6Lf7jP0SAAAAAKDw2YOCMgkwbXfNO3-SG2yf1cTH'
os.environ['RECAPTCHA_PRIVATE_KEY'] = \
    '6Lf7jP0SAAAAAKHYkfIMAGQSMMV_FNnpIeolOM0K'
os.environ['SECRET_KEY'] = 'tilsecret'
os.environ['TEST'] = 'False'
os.environ['DEBUG'] = 'True'

# Create a test client
app = create_app().test_client()


def test_home():
    '''testing /'''
    rv = app.get('/')
    assert 'A place to share your TIL' in rv.data


def test_til():
    '''testing /til'''
    rv = app.get('/til/1')
    assert 'blockquote' in rv.data
    assert 'small' in rv.data


"""  # Fails maybe because `referer` isn't defined.
def test_comment():
 def test_dev_config(self):
     """ASSERTS THAT APP NAME IS APP"""
     base_config = BaseConfig
     flask_app = app.create_app(base_config)
     self.assertEqual('marketing-lead-scoring', flask_app.name)
Exemple #23
0
def app() -> FastAPI:
    """ test app """
    app = create_app(title="테스트")
    app.include_router(api_v1, prefix=f"{settings.API_VERSION_PREFIX}")
    return app
Exemple #24
0
from src.main import create_app

application = create_app()

if __name__ == '__main__':
    application.run(host='0.0.0.0', port=8080)
Exemple #25
0
import os
import unittest

from flask_migrate import Migrate, MigrateCommand
from flask_script import Manager

from src import blueprint
from src.main import create_app, db
from src.main.model import sowing_form

from src.data.model import plot, sow, application, harvest, issue

app = create_app(os.getenv('BOILERPLATE_ENV') or 'dev')
app.register_blueprint(blueprint)

app.app_context().push()

manager = Manager(app)
migrate = Migrate(app, db)

manager.add_command('db', MigrateCommand)


@manager.command
def run():
    app.run()


@manager.command
def test():
    """Runs the unit tests."""
Exemple #26
0
 def setUp(self):
     """Setting up pre-requisite"""
     self.app = create_app()
     self.client = self.app.test_client