Browse Source

Create database before running the migrations

Will teardown the database at the end of the test case
Peter Justin 7 years ago
parent
commit
de4a4c0f00
1 changed files with 6 additions and 0 deletions
  1. 6 0
      tests/unit/utils/test_populate.py

+ 6 - 0
tests/unit/utils/test_populate.py

@@ -1,5 +1,6 @@
 import pytest
 from sqlalchemy.exc import OperationalError
+from sqlalchemy_utils.functions import create_database, drop_database
 
 from flaskbb.extensions import alembic, db
 from flaskbb.utils.populate import delete_settings_from_fixture, \
@@ -246,5 +247,10 @@ def test_migrations_upgrade():
     with pytest.raises(OperationalError):
         User.query.all()
 
+    # ensure that the database is created
+    create_database(db.engine.url)
+
     alembic.upgrade()
     assert len(User.query.all()) == 0
+
+    drop_database(db.engine.url)