Skip to content

Commit

Permalink
fix: app context code
Browse files Browse the repository at this point in the history
  • Loading branch information
alguadam committed Oct 1, 2023
1 parent 12d7d65 commit 616c97d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
4 changes: 3 additions & 1 deletion iebank_api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
db = SQLAlchemy(app)

from iebank_api.models import Account
db.create_all()

with app.app_context():
db.create_all()
CORS(app)

from iebank_api import routes
Expand Down
13 changes: 8 additions & 5 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@
from iebank_api import db, app



@pytest.fixture
def testing_client(scope='module'):
db.create_all()
account = Account('Test Account', '€')
db.session.add(account)
db.session.commit()
with app.app_context():
db.create_all()
account = Account('Test Account', '€')
db.session.add(account)
db.session.commit()

with app.test_client() as testing_client:
yield testing_client

db.drop_all()
with app.app_context():
db.drop_all()

0 comments on commit 616c97d

Please sign in to comment.