Fix session.execute in integration test utils

This commit is contained in:
rubenwardy 2023-05-13 19:12:52 +01:00
parent fe64f15949
commit adbbaf93c6

@ -1,15 +1,18 @@
import pytest, json
from sqlalchemy import text
from app import app
from app.models import db, User
from app.default_data import populate
def clear_data(session):
meta = db.metadata
for table in reversed(meta.sorted_tables):
session.execute(f'ALTER TABLE "{table.name}" DISABLE TRIGGER ALL;')
session.execute(text(f'ALTER TABLE "{table.name}" DISABLE TRIGGER ALL;'))
session.execute(table.delete())
session.execute(f'ALTER TABLE "{table.name}" ENABLE TRIGGER ALL;')
#session.execute(table.delete())
session.execute(text(f'ALTER TABLE "{table.name}" ENABLE TRIGGER ALL;'))
def recreate_db():
clear_data(db.session)