diff --git a/tests/test_database.py b/tests/test_database.py index 0ea63c6..7f1e812 100644 --- a/tests/test_database.py +++ b/tests/test_database.py @@ -1,4 +1,3 @@ -from email.policy import default from config import Config from metatube.init import Default from metatube import create_app, db @@ -39,6 +38,11 @@ def testAutoCreation(self): db.drop_all() relative_url = 'sqlite:///' + os.path.join('metatube', Config.SQLALCHEMY_DATABASE_URI.replace('sqlite:///', '')) default = Default(self.app, relative_url) + migrationsPath = os.path.join(Config.BASE_DIR, 'migrations') + if os.path.exists(migrationsPath) and os.path.isdir(migrationsPath) and (os.path.exists(os.path.join(migrationsPath, 'env.py')) and os.path.exists(os.path.join(migrationsPath, 'versions'))): + default.init_db() + else: + default.init_db(False) self.assertTrue(default.init_db()) def testConfigTable(self):