Files
NtR-soudcloud-fetcher/tests/test_db.py
2026-03-12 01:21:33 -04:00

31 lines
666 B
Python

import sqlite3
import pytest
from ntr_fetcher.db import Database
@pytest.fixture
def db(tmp_path):
db_path = str(tmp_path / "test.db")
database = Database(db_path)
database.initialize()
return database
def test_tables_created(db):
conn = sqlite3.connect(db.path)
cursor = conn.execute(
"SELECT name FROM sqlite_master WHERE type='table' ORDER BY name"
)
tables = [row[0] for row in cursor.fetchall()]
conn.close()
assert "tracks" in tables
assert "shows" in tables
assert "show_tracks" in tables
def test_initialize_idempotent(db):
"""Calling initialize twice doesn't raise."""
db.initialize()