Simple test for create_app

This commit is contained in:
Kfir Hadas 2017-08-03 01:06:25 +03:00
parent 85688629b7
commit f8c939d750
1 changed files with 31 additions and 0 deletions

31
tests/test_app_factory.py Normal file
View 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()