"""{{ display_name }} MCP server — generated by mcpify. Do not hand-edit."""

from __future__ import annotations

import time

from {{ module_name }}.core.cache import QueryCache


def test_returns_a_previously_set_value() -> None:
    cache: QueryCache[str] = QueryCache(max_size=10, ttl_s=60.0)
    cache.set("key", "value")
    assert cache.get("key") == "value"


def test_expires_entries_past_their_ttl() -> None:
    cache: QueryCache[str] = QueryCache(max_size=10, ttl_s=0.01)
    cache.set("key", "value")
    time.sleep(0.05)
    assert cache.get("key") is None


def test_evicts_when_full() -> None:
    cache: QueryCache[str] = QueryCache(max_size=1, ttl_s=60.0)
    cache.set("a", "1")
    cache.set("b", "2")
    remaining = [v for v in (cache.get("a"), cache.get("b")) if v is not None]
    assert len(remaining) == 1
