fix: update test fixtures for SQLite storage migration
Some checks failed
Lint & Test / test (push) Failing after 1m33s

All store tests were passing file paths instead of Database objects
after the JSON-to-SQLite migration. Updated fixtures to create temp
Database instances, rewrote backup e2e tests for binary .db format,
and fixed config tests for the simplified StorageConfig.
This commit is contained in:
2026-03-25 11:38:07 +03:00
parent 9dfd2365f4
commit 2da5c047f9
12 changed files with 135 additions and 126 deletions

View File

@@ -14,13 +14,16 @@ from wled_controller.storage.device_store import Device, DeviceStore
@pytest.fixture
def temp_storage(tmp_path) -> Path:
return tmp_path / "devices.json"
def tmp_db(tmp_path):
from wled_controller.storage.database import Database
db = Database(tmp_path / "test.db")
yield db
db.close()
@pytest.fixture
def store(temp_storage) -> DeviceStore:
return DeviceStore(temp_storage)
def store(tmp_db) -> DeviceStore:
return DeviceStore(tmp_db)
# ---------------------------------------------------------------------------
@@ -240,23 +243,29 @@ class TestDeviceNameUniqueness:
class TestDevicePersistence:
def test_persistence_across_instances(self, temp_storage):
s1 = DeviceStore(temp_storage)
def test_persistence_across_instances(self, tmp_path):
from wled_controller.storage.database import Database
db = Database(tmp_path / "persist.db")
s1 = DeviceStore(db)
d = s1.create_device(name="Persist", url="http://p", led_count=77)
did = d.id
s2 = DeviceStore(temp_storage)
s2 = DeviceStore(db)
loaded = s2.get_device(did)
assert loaded.name == "Persist"
assert loaded.led_count == 77
db.close()
def test_update_persists(self, temp_storage):
s1 = DeviceStore(temp_storage)
def test_update_persists(self, tmp_path):
from wled_controller.storage.database import Database
db = Database(tmp_path / "persist2.db")
s1 = DeviceStore(db)
d = s1.create_device(name="Before", url="http://x", led_count=10)
s1.update_device(d.id, name="After")
s2 = DeviceStore(temp_storage)
s2 = DeviceStore(db)
assert s2.get_device(d.id).name == "After"
db.close()
# ---------------------------------------------------------------------------
@@ -266,7 +275,9 @@ class TestDevicePersistence:
class TestDeviceThreadSafety:
def test_concurrent_creates(self, tmp_path):
s = DeviceStore(tmp_path / "conc.json")
from wled_controller.storage.database import Database
db = Database(tmp_path / "conc.db")
s = DeviceStore(db)
errors = []
def _create(i):