mirror of
https://gitlab.com/SIGBUS/nyaa.git
synced 2024-11-18 09:27:45 +00:00
87dd95f1e0
* Replace all `from nyaa import app` imports with `app = flask.current_app` (or `from flask import current_app as app` where possible) * Add a separate config object for top-level and class statements as `nyaa.extensions.config` Required because those codes don't have app context at the time of evaluation/execution. * Remove `routes.py` file and register all blueprints in `nyaa/__init__.py` * Refactor `nyaa/__init__.py` into an app factory * Update tools * Update tests (temporary, will be replaced)
38 lines
1 KiB
Python
38 lines
1 KiB
Python
""" Sets up helper class for testing """
|
|
|
|
import os
|
|
import unittest
|
|
|
|
from nyaa import create_app
|
|
|
|
USE_MYSQL = True
|
|
|
|
|
|
class NyaaTestCase(unittest.TestCase):
|
|
|
|
@classmethod
|
|
def setUpClass(cls):
|
|
app = create_app('config')
|
|
app.config['TESTING'] = True
|
|
cls.app_context = app.app_context()
|
|
|
|
# Use a seperate database for testing
|
|
# if USE_MYSQL:
|
|
# cls.db_name = 'nyaav2_tests'
|
|
# db_uri = 'mysql://root:@localhost/{}?charset=utf8mb4'.format(cls.db_name)
|
|
# else:
|
|
# cls.db_name = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'test.db')
|
|
# db_uri = 'sqlite:///{}?check_same_thread=False'.format(cls.db_name)
|
|
|
|
# if not os.environ.get('TRAVIS'): # Travis doesn't need a seperate DB
|
|
# app.config['USE_MYSQL'] = USE_MYSQL
|
|
# app.config['SQLALCHEMY_DATABASE_URI'] = db_uri
|
|
|
|
with cls.app_context:
|
|
cls.app = app.test_client()
|
|
|
|
@classmethod
|
|
def tearDownClass(cls):
|
|
with cls.app_context:
|
|
pass
|