Files
syncthing-blade-mcp/tests/test_tools_devices.py
T
Piers Dawson-DamerandClaude Opus 4.6 3a33d34bd1 Refactor into package, add 6 new tools, add 96 tests
Split the monolithic syncthing_mcp.py into a proper src/syncthing_mcp/
package with focused modules: client, models, registry, server, and
tool submodules (system, folders, devices, config, instances).

New tools: browse_folder, file_info, folder_need (file-level queries),
override_folder, revert_folder (conflict resolution), check_upgrade
(system management). Bumps tool count from 30 to 36.

Adds comprehensive test suite (96 tests) using pytest + respx for
HTTP mocking, covering client methods, registry logic, model validation,
and all tool functions.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 10:13:37 +11:00

54 lines
1.5 KiB
Python

"""Tests for device tools (list, completion, connections)."""
import json
import pytest
from syncthing_mcp.models import DeviceInput, EmptyInput
from syncthing_mcp.registry import reload_instances
from tests.conftest import (
BASE_URL,
DEVICE_ID_LOCAL,
DEVICE_ID_REMOTE,
make_completion,
)
@pytest.fixture(autouse=True)
def _setup(single_instance_env):
reload_instances()
yield
reload_instances()
class TestListDevices:
async def test_returns_devices(self, mock_api):
from syncthing_mcp.tools.devices import syncthing_list_devices
result = json.loads(await syncthing_list_devices(EmptyInput()))
assert len(result) == 2
names = {d["name"] for d in result}
assert "local-dev" in names
assert "remote-dev" in names
class TestDeviceCompletion:
async def test_fully_synced(self, mock_api):
from syncthing_mcp.tools.devices import syncthing_device_completion
mock_api.get("/rest/db/completion").respond(json=make_completion(100.0))
result = json.loads(await syncthing_device_completion(
DeviceInput(device_id=DEVICE_ID_REMOTE)
))
assert result["completion"] == 100.0
assert result["needBytes"] == 0
class TestConnections:
async def test_returns_connections(self, mock_api):
from syncthing_mcp.tools.devices import syncthing_connections
result = json.loads(await syncthing_connections(EmptyInput()))
assert len(result) == 2
assert any(c["connected"] for c in result)