fixed tests
This commit is contained in:
@@ -4,7 +4,6 @@ from pathlib import Path
|
||||
|
||||
import aiosqlite
|
||||
import pytest
|
||||
|
||||
from app.db import init_db
|
||||
|
||||
|
||||
@@ -14,9 +13,7 @@ async def test_init_db_creates_settings_table(tmp_path: Path) -> None:
|
||||
db_path = str(tmp_path / "test.db")
|
||||
async with aiosqlite.connect(db_path) as db:
|
||||
await init_db(db)
|
||||
async with db.execute(
|
||||
"SELECT name FROM sqlite_master WHERE type='table' AND name='settings';"
|
||||
) as cursor:
|
||||
async with db.execute("SELECT name FROM sqlite_master WHERE type='table' AND name='settings';") as cursor:
|
||||
row = await cursor.fetchone()
|
||||
assert row is not None
|
||||
|
||||
@@ -27,9 +24,7 @@ async def test_init_db_creates_sessions_table(tmp_path: Path) -> None:
|
||||
db_path = str(tmp_path / "test.db")
|
||||
async with aiosqlite.connect(db_path) as db:
|
||||
await init_db(db)
|
||||
async with db.execute(
|
||||
"SELECT name FROM sqlite_master WHERE type='table' AND name='sessions';"
|
||||
) as cursor:
|
||||
async with db.execute("SELECT name FROM sqlite_master WHERE type='table' AND name='sessions';") as cursor:
|
||||
row = await cursor.fetchone()
|
||||
assert row is not None
|
||||
|
||||
@@ -53,9 +48,7 @@ async def test_init_db_creates_import_log_table(tmp_path: Path) -> None:
|
||||
db_path = str(tmp_path / "test.db")
|
||||
async with aiosqlite.connect(db_path) as db:
|
||||
await init_db(db)
|
||||
async with db.execute(
|
||||
"SELECT name FROM sqlite_master WHERE type='table' AND name='import_log';"
|
||||
) as cursor:
|
||||
async with db.execute("SELECT name FROM sqlite_master WHERE type='table' AND name='import_log';") as cursor:
|
||||
row = await cursor.fetchone()
|
||||
assert row is not None
|
||||
|
||||
@@ -75,12 +68,10 @@ async def test_init_db_records_schema_version(tmp_path: Path) -> None:
|
||||
db_path = str(tmp_path / "test.db")
|
||||
async with aiosqlite.connect(db_path) as db:
|
||||
await init_db(db)
|
||||
async with db.execute(
|
||||
"SELECT version FROM schema_migrations ORDER BY version DESC LIMIT 1;"
|
||||
) as cursor:
|
||||
async with db.execute("SELECT version FROM schema_migrations ORDER BY version DESC LIMIT 1;") as cursor:
|
||||
row = await cursor.fetchone()
|
||||
assert row is not None
|
||||
assert row[0] == 2
|
||||
assert row[0] == 9
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@@ -92,9 +83,7 @@ async def test_init_db_migrates_legacy_database_without_schema_version(tmp_path:
|
||||
await db.execute("DROP TABLE schema_migrations;")
|
||||
await db.commit()
|
||||
await init_db(db)
|
||||
async with db.execute(
|
||||
"SELECT version FROM schema_migrations ORDER BY version DESC LIMIT 1;"
|
||||
) as cursor:
|
||||
async with db.execute("SELECT version FROM schema_migrations ORDER BY version DESC LIMIT 1;") as cursor:
|
||||
row = await cursor.fetchone()
|
||||
assert row is not None
|
||||
assert row[0] == 2
|
||||
assert row[0] == 9
|
||||
|
||||
Reference in New Issue
Block a user