From 02311eab7604d29de7b70721cb1e10329178cfc7 Mon Sep 17 00:00:00 2001 From: Kevin Morris Date: Mon, 29 Mar 2021 15:20:34 -0700 Subject: [PATCH] add test_initdb.py IMPORTANT: This test completely wipes out the database it's using. Make sure you've got AUR_CONFIG set to a test database configuration! Signed-off-by: Kevin Morris --- test/test_initdb.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 test/test_initdb.py diff --git a/test/test_initdb.py b/test/test_initdb.py new file mode 100644 index 00000000..ff089b63 --- /dev/null +++ b/test/test_initdb.py @@ -0,0 +1,27 @@ +import pytest + +import aurweb.config +import aurweb.db +import aurweb.initdb + +from aurweb.models.account_type import AccountType +from aurweb.schema import metadata +from aurweb.testing import setup_test_db + + +@pytest.fixture(autouse=True) +def setup(): + setup_test_db() + + tables = metadata.tables.keys() + for table in tables: + aurweb.db.session.execute(f"DROP TABLE IF EXISTS {table}") + + +def test_run(): + class Args: + use_alembic = True + verbose = False + aurweb.initdb.run(Args()) + assert aurweb.db.session.query(AccountType).filter( + AccountType.AccountType == "User").first() is not None