aurweb/test/test_initdb.py
moson d7ecede2eb
fix(deps): upgrade to sqlalchemy version 2
Bump sqlalchemy to version 2.0.22

There are quite some changes that happened with v2.
We are currently relying on the "auto-commit" feature which was removed.
For the moment we can use a wrapper class to mimic the auto-commit
behavior allowing us to move to v2.

Ultimately, the (db) session management needs some overhaul though.

Signed-off-by: moson <moson@archlinux.org>
2023-11-30 15:19:58 +01:00

29 lines
631 B
Python

import pytest
import aurweb.config
import aurweb.db
import aurweb.initdb
from aurweb.models.account_type import AccountType
@pytest.fixture(autouse=True)
def setup(db_test):
return
class Args:
use_alembic = True
verbose = True
def test_run():
from aurweb.schema import metadata
aurweb.db.kill_engine()
metadata.drop_all(aurweb.db.get_engine(), checkfirst=False)
aurweb.initdb.run(Args())
# Check that constant table rows got added via initdb.
with aurweb.db.begin():
record = aurweb.db.query(AccountType, AccountType.AccountType == "User").first()
assert record is not None