Files
intervalsicu-mcp/tests/test_value.py
Chris Farhood 935abf86d4
build-image / build (push) Failing after 18s
Fork intervals-mcp-server: native OAuth + streamable-HTTP, no monkeypatch
- Bump mcp[cli] 1.22 -> 1.28.1 (negotiates MCP protocol 2025-11-25, matching
  current Claude clients; the old 2025-06-18 server never got a tools/list on
  the connector surface).
- Bake transport config into code: stateless_http + json_response for HTTP
  (single JSON body instead of a 34KB SSE stream, which the connector pipeline
  handles far more reliably).
- Bake Authentik OAuth (AuthSettings + JWT TokenVerifier) into intervals_mcp_server.auth,
  configured from MCP_ISSUER/MCP_RESOURCE/MCP_JWKS_URI/MCP_CLIENT_ID — removes the
  runtime FastMCP.__init__ monkeypatch from the k8s deployment command.
- Accept token audience with/without trailing slash (RFC 8707 clients use the
  slash-normalised resource metadata value).
- Dockerfile CMD runs the module (transport via MCP_TRANSPORT); add .gitea CI to
  build+push the image to git.farh.net/farhoodlabs/intervalsicu-mcp.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-04 15:07:46 -04:00

39 lines
1.3 KiB
Python

"""
Unit tests for the Value dataclass in intervals_mcp_server.utils.types.
These tests verify that the Value dataclass correctly handles:
- String formatting for percent FTP units
- Ramp intervals (start/end values)
- Deserialisation of pace/swim-pace unit strings returned by the Intervals.icu API
"""
import pytest
from intervals_mcp_server.utils.types import Value, ValueUnits
def test_str_percent_ftp():
"""Test formatting percentage FTP values."""
val = Value(value=95.0, units=ValueUnits.PERCENT_FTP)
assert str(val) == "95% ftp"
def test_str_ramp_percent_ftp():
"""Test formatting ramp intervals with percentage FTP."""
val = Value(start=65, end=85, units=ValueUnits.PERCENT_FTP)
assert str(val) == "65%-85% ftp"
@pytest.mark.parametrize("unit_str,expected_enum", [
("MINS_KM", ValueUnits.MINS_KM),
("MINS_MILE", ValueUnits.MINS_MILE),
("SECS_100M", ValueUnits.SECS_100M),
("SECS_500M", ValueUnits.SECS_500M),
])
def test_pace_units_deserialise_from_api_string(unit_str, expected_enum):
"""Pace/swim-pace unit strings returned by the Intervals.icu API must round-trip
through Value.from_dict without raising ValueError. This test would fail if any
of these unit strings were missing from the ValueUnits enum."""
val = Value.from_dict({"value": 5.0, "units": unit_str})
assert val.units == expected_enum