2017-07-07 21:14:37 +00:00
|
|
|
""" Sets up helper class for testing """
|
|
|
|
|
2017-08-02 21:39:43 +00:00
|
|
|
import os.path as op
|
2017-07-07 21:14:37 +00:00
|
|
|
import unittest
|
|
|
|
|
2017-08-01 18:02:08 +00:00
|
|
|
from nyaa import create_app
|
2017-07-07 21:14:37 +00:00
|
|
|
|
|
|
|
USE_MYSQL = True
|
|
|
|
|
|
|
|
|
|
|
|
class NyaaTestCase(unittest.TestCase):
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def setUpClass(cls):
|
2017-08-01 18:02:08 +00:00
|
|
|
app = create_app('config')
|
2017-07-07 21:14:37 +00:00
|
|
|
app.config['TESTING'] = True
|
|
|
|
|
|
|
|
# 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:
|
2017-08-02 21:39:43 +00:00
|
|
|
# cls.db_name = op.abspath(op.join(op.dirname(__file__)), 'test.db')
|
2017-07-07 21:14:37 +00:00
|
|
|
# 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
|
|
|
|
|
2017-07-14 23:49:23 +00:00
|
|
|
cls.app = app
|
|
|
|
cls.app_context = app.app_context()
|
2017-08-02 21:39:43 +00:00
|
|
|
cls.request_context = app.test_request_context
|
2017-07-14 23:49:23 +00:00
|
|
|
|
2017-07-07 21:14:37 +00:00
|
|
|
with cls.app_context:
|
2017-07-14 23:49:23 +00:00
|
|
|
cls.client = app.test_client()
|
2017-07-07 21:14:37 +00:00
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def tearDownClass(cls):
|
|
|
|
with cls.app_context:
|
|
|
|
pass
|