mirror of
https://gitlab.com/SIGBUS/nyaa.git
synced 2024-12-22 19:49:59 +00:00
Simple test for create_app
This commit is contained in:
parent
85688629b7
commit
f8c939d750
31
tests/test_app_factory.py
Normal file
31
tests/test_app_factory.py
Normal file
|
@ -0,0 +1,31 @@
|
|||
import os
|
||||
import os.path as op
|
||||
import unittest
|
||||
|
||||
from nyaa import create_app
|
||||
|
||||
|
||||
class CustomConfig(object):
|
||||
DEBUG = True
|
||||
SQLALCHEMY_DATABASE_URI = 'sqlite:///:memory:'
|
||||
SECRET_KEY = '***' # For DebugToolbar
|
||||
LOG_FILE = op.abspath(op.join(op.dirname(__file__), 'test.log'))
|
||||
|
||||
|
||||
class TestAppFactory(unittest.TestCase):
|
||||
def setUp(self):
|
||||
if op.isfile(CustomConfig.LOG_FILE):
|
||||
os.remove(CustomConfig.LOG_FILE)
|
||||
|
||||
def test_create_app(self):
|
||||
# config is usually a class or a module
|
||||
app = create_app(config=CustomConfig)
|
||||
|
||||
self.assertIn('DEBUG', app.config)
|
||||
self.assertTrue(app.config['DEBUG'])
|
||||
|
||||
del app
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
Loading…
Reference in a new issue