Files
computer-playbook/tests/unit/python/utils/inventory/test_tools_model.py
T
kevinveenbirkenbachandClaude Opus 5 9ecedfac92 test(lint): read the files these tests write without the session cache
Both new tests read a file their own run has just written, which the uncached-read lint flags because utils.cache.files.read_text is an lru_cache with no mtime invalidation. The two cases want different answers. The rendered inventory is YAML, so load_yaml_any reads and parses it the way the lint asks and needs no exception at all. The healthcheck probe writes its request through bash inside the test, so a cached read would compare against the previous run's bytes and the assertion would pass without proving anything; that one keeps a cache-read directive naming why.

make test-lint went from 2 failed to green, and the first attempt is the reason the inventory test carries no directive: suppressing the read there only moved the complaint to yaml.safe_load, which the right reader answers in one call.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-10-18 10:57:20 +02:00

36 lines
1.2 KiB
Python

"""The alias the readiness probe expects is the one the lane deploys."""
from __future__ import annotations
import unittest
from utils import PROJECT_ROOT
from utils.cache.yaml import load_yaml_any
from utils.inventory.tools import LANE_MODEL_ALIAS, render
OLLAMA_ROLE = "svc-ai-ollama"
class TestLaneModel(unittest.TestCase):
def test_the_rendered_inventory_pins_the_alias_the_probe_expects(self) -> None:
"""Two places name the model, and nothing else keeps them equal.
The inventory carries the entry because that is where inventory data
belongs, and the probe needs the bare alias before any render has
run, because ``ensure`` asks whether the lane serves before the
deploy that writes the rendered file. A lane serving one model while
the probe expects another never reports ready and redeploys on every
call.
"""
rendered = load_yaml_any(str(render(PROJECT_ROOT, ["en"])))
ollama = rendered["applications"][OLLAMA_ROLE]["services"]["ollama"]
self.assertEqual(
[LANE_MODEL_ALIAS],
[model["alias"] for model in ollama["preload_models"]],
)
if __name__ == "__main__":
unittest.main()