Initial commit: Shelly Manager with Textual CLI, Streamlit UI, and comprehensive .gitignore
Shelly device management app with mDNS/subnet discovery, inventory, configuration, and mass operations for Gen1/Gen2+ devices. Includes .gitignore excluding runtime data (device DB, user config), AI conversation history, build artifacts, and common Python/OS patterns.
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
"""Storage backend tests."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
|
||||
from datetime import UTC, datetime
|
||||
|
||||
from shelly_manager.core.models import DeviceFilter, ShellyDevice
|
||||
from shelly_manager.storage.markdown_backend import MarkdownStorage
|
||||
from shelly_manager.storage.sqlite_backend import SqliteStorage
|
||||
|
||||
|
||||
def _sample_device() -> ShellyDevice:
|
||||
return ShellyDevice(
|
||||
id="AABBCCDDEEFF",
|
||||
name="Test",
|
||||
mac="AA:BB:CC:DD:EE:FF",
|
||||
ip="10.0.0.1",
|
||||
generation=2,
|
||||
model="Plus1",
|
||||
firmware="1.2.3",
|
||||
online=True,
|
||||
last_seen=datetime.now(UTC),
|
||||
capabilities=["switch"],
|
||||
status={"a": 1},
|
||||
settings={"b": 2},
|
||||
tags=["x"],
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_sqlite_roundtrip(app_config_sqlite) -> None:
|
||||
s = SqliteStorage(app_config_sqlite.sqlite_path)
|
||||
d = _sample_device()
|
||||
await s.save_device(d)
|
||||
loaded = await s.get_device(d.id)
|
||||
assert loaded is not None
|
||||
assert loaded.ip == d.ip
|
||||
assert loaded.settings == d.settings
|
||||
lst = await s.list_devices(DeviceFilter(generations=[2]))
|
||||
assert len(lst) == 1
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_markdown_roundtrip(app_config_markdown) -> None:
|
||||
s = MarkdownStorage(app_config_markdown.markdown_dir)
|
||||
d = _sample_device()
|
||||
await s.save_device(d)
|
||||
loaded = await s.get_device(d.id)
|
||||
assert loaded is not None
|
||||
assert loaded.model == d.model
|
||||
lst = await s.list_devices(None)
|
||||
assert len(lst) == 1
|
||||
Reference in New Issue
Block a user