diff --git a/tests/test_app_factory.py b/tests/test_app_factory.py new file mode 100644 index 0000000..2803175 --- /dev/null +++ b/tests/test_app_factory.py @@ -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()