release: nexus btpanel session fix and app-v2
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
"""GET /api/settings/{key} defaults when row missing."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from unittest.mock import AsyncMock, MagicMock, patch
|
||||
|
||||
import pytest
|
||||
from fastapi import HTTPException
|
||||
|
||||
from server.api.settings import SETTING_DEFAULTS, get_setting
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_get_push_complete_sound_default_when_missing():
|
||||
admin = MagicMock()
|
||||
db = AsyncMock()
|
||||
with patch("server.api.settings.SettingRepositoryImpl") as repo_cls:
|
||||
repo_cls.return_value.get = AsyncMock(return_value=None)
|
||||
out = await get_setting("push_complete_sound", admin=admin, db=db)
|
||||
assert out["key"] == "push_complete_sound"
|
||||
assert out["value"] == SETTING_DEFAULTS["push_complete_sound"]
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_get_unknown_key_still_404():
|
||||
admin = MagicMock()
|
||||
db = AsyncMock()
|
||||
with patch("server.api.settings.SettingRepositoryImpl") as repo_cls:
|
||||
repo_cls.return_value.get = AsyncMock(return_value=None)
|
||||
with pytest.raises(HTTPException) as exc:
|
||||
await get_setting("nonexistent_setting_key", admin=admin, db=db)
|
||||
assert exc.value.status_code == 404
|
||||
Reference in New Issue
Block a user