Skip to content

Add unit tests for server tools#6

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/add-unit-tests-for-server
Draft

Add unit tests for server tools#6
Copilot wants to merge 3 commits intomainfrom
copilot/add-unit-tests-for-server

Conversation

Copy link
Contributor

Copilot AI commented Feb 3, 2026

Following PR #3's model tests, this adds unit tests for the 6 server tools (search_sites, get_site_context, search_devices, get_device_context, read_blueprint, get_historical_telemetry).

Changes

New test file: tests/unit/mcp/test_server.py (16 tests, 785 LOC)

  • Pagination: Tests offset/limit behavior across search_sites, search_devices, read_blueprint
  • Regex filtering: Name and timezone pattern matching
  • Context generation: Site statistics (device counts, gateway detection) and device context (connectivity, properties, telemetry, blueprint)
  • Blueprint sections: Properties, telemetry, alerts with pattern filtering
  • Historical telemetry: Time-series retrieval with granularity

Test structure

class TestServerSearchSites:
    async def test_search_sites_basic(self) -> None:
    async def test_search_sites_pagination(self) -> None:
    # ... pattern filtering tests

class TestServerGetDeviceContext:
    async def test_get_device_context(self) -> None:
        # Validates connectivity, properties, telemetry, blueprint

Uses AsyncMock for HTTP client mocking and a custom MockAsyncStream for API response streams.

Coverage: 86% server.py, 96% overall (29 total unit tests)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits February 3, 2026 16:37
Co-authored-by: rnovatorov <20299819+rnovatorov@users.noreply.github.com>
Co-authored-by: rnovatorov <20299819+rnovatorov@users.noreply.github.com>
Copilot AI changed the title [WIP] Add unit tests for server functionalities Add unit tests for server tools Feb 3, 2026
Copilot AI requested a review from rnovatorov February 3, 2026 16:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants