Skip to content

Commit

Permalink
Fix tests with stamping feature
Browse files Browse the repository at this point in the history
  • Loading branch information
multimeric committed Aug 5, 2020
1 parent e4526f7 commit f2d3192
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
5 changes: 3 additions & 2 deletions megaqc/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
from builtins import object
from copy import copy

from flask_migrate import stamp
from past.builtins import basestring
from sqlalchemy import create_engine, inspect
from sqlalchemy.engine.url import make_url
from sqlalchemy.exc import OperationalError, ProgrammingError

from .compat import basestring
from .extensions import db, migrate
from .extensions import db

# Alias common SQLAlchemy names
Column = db.Column
Expand Down Expand Up @@ -195,6 +196,6 @@ def init_db(url):
db.metadata.create_all()

# Tell alembic that we're at the latest migration, since we just created everything from scratch
migrate.stamp()
stamp()

print("Initialized the database.")
4 changes: 3 additions & 1 deletion megaqc/extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
Each extension is initialized in the app factory located in app.py.
"""
from pathlib import Path

from flask_caching import Cache
from flask_debugtoolbar import DebugToolbarExtension
from flask_login import LoginManager
Expand All @@ -21,5 +23,5 @@
cache = Cache()
debug_toolbar = DebugToolbarExtension()
restful = Api(prefix="/rest_api/v1")
migrate = Migrate()
migrate = Migrate(directory=str(Path(__file__).parent / "migrations"))
json_api = JsonApi()
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ def app():
An application for the tests.
"""
config = TestConfig()
init_db(config.SQLALCHEMY_DATABASE_URI)
_app = create_app(config)
ctx = _app.test_request_context()
ctx.push()
init_db(config.SQLALCHEMY_DATABASE_URI)

yield _app

Expand Down

0 comments on commit f2d3192

Please sign in to comment.