Пример #1
0
def create_app(config_name):
    """Instantiate Flask app
    Including database, blueprints and etc.
    """
    logger.info(__name__ + "  " + config[config_name].SQLALCHEMY_DATABASE_URI)
    app = Flask(__name__)
    app.config.from_object(config[config_name])
    Bootstrap(app)
    PAGEDOWN.init_app(app)
    LOGIN_MANAGER.init_app(app)

    # Initialize database and ORM.
    # If tables are not exist yet, create a new one.
    from app.alchemy_model import DB
    #with app.app_context():
    logger.info(__name__ + "test DB")
    DB.init_app(app)
    if not os.path.isfile(config[config_name].DB_PATH):
        open(config[config_name].DB_PATH, 'w+')
        DB.drop_all(app=app)
        DB.create_all(app=app)
    # Register all blueprints to app
    from .main import main as main_blueprint
    from .auth import auth as auth_blueprint
    app.register_blueprint(main_blueprint)
    app.register_blueprint(auth_blueprint)

    app.jinja_env.add_extension('jinja2.ext.do')
    return app
Пример #2
0
def cog(bot: commands.Bot):
    cog = Voting(bot)
    insert_extension("Vote", 0, True, True)
    bot.add_cog(cog)
    dpytest.configure(bot)
    logger.info("Tests starting")
    return cog
Пример #3
0
def teardown_config():

    # yield, to let all tests within the scope run
    yield

    # tear_down: then clear table at the end of the scope
    logger.info("Tearing down session")

    from koala.utils import get_arg_config_path

    shutil.rmtree(get_arg_config_path(), ignore_errors=True)
Пример #4
0
def intro_cog(bot):
    intro_cog = IntroCog(bot)
    bot.add_cog(intro_cog)
    dpytest.configure(bot)
    logger.info("Tests starting")
    return intro_cog
Пример #5
0
def utils_cog(bot):
    utils_cog = LastCtxCog(bot)
    bot.add_cog(utils_cog)
    dpytest.configure(bot)
    logger.info("Tests starting")
    return utils_cog
Пример #6
0
def announce_cog(bot: discord.ext.commands.Bot):
    announce_cog = announce.Announce(bot)
    bot.add_cog(announce_cog)
    dpytest.configure(bot, 2, 1, 2)
    logger.info("Tests starting")
    return announce_cog
Пример #7
0
"""initialize Blueprint auth"""
from tests.log import logger, set_log
from flask import Blueprint

auth = Blueprint('auth', __name__, template_folder='./templates', static_folder='../static')
logger.info("initialize Blueprint 'auth', root_path is:" + auth.root_path)
from .import views 
Пример #8
0
async def tf_cog(bot: discord.ext.commands.Bot):
    tf_cog = TextFilterCog(bot)
    bot.add_cog(tf_cog)
    dpytest.configure(bot)
    logger.info("Tests starting")
    return tf_cog
Пример #9
0
def base_cog(bot: discord.ext.commands.Bot):
    base_cog = BaseCog(bot)
    bot.add_cog(base_cog)
    dpytest.configure(bot)
    logger.info("Tests starting")
    return base_cog
Пример #10
0
"""initialize Blueprint main"""
from tests.log import logger, set_log
from flask import Blueprint

main = Blueprint('main',
                 __name__,
                 template_folder='./templates',
                 static_folder='../static')
logger.info("initialize Blueprint 'main', root_path is:" + main.root_path)
from . import views, errors
Пример #11
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from tests.log import logger

logger.info('*' * 36)
logger.error('*' * 36)
Пример #12
0
def cog(bot: commands.Bot):
    cog = Verification(bot)
    bot.add_cog(cog)
    dpytest.configure(bot)
    logger.info("Tests starting")
    return cog
Пример #13
0
def role_colour_cog(bot):
    role_colour_cog = ColourRole(bot)
    bot.add_cog(role_colour_cog)
    dpytest.configure(bot)
    logger.info("Tests starting")
    return role_colour_cog