Fix duplicate get_by_cid method shadowing recipe lookup

Bug: Two get_by_cid methods existed in L1CacheManager. The second
definition shadowed the first, breaking recipe lookup because the
comprehensive method (using find_by_cid) was hidden.

- Remove duplicate get_by_cid method (lines 470-494)
- Add regression test to ensure only one get_by_cid exists
- Add tests for template variables and recipe visibility

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
gilesb
2026-01-12 12:14:59 +00:00
parent 977d9a9258
commit 9f8aa54e2b
3 changed files with 140 additions and 27 deletions

View File

@@ -1,5 +1,5 @@
"""
Tests for run artifacts data structure.
Tests for run artifacts data structure and template variables.
Bug found 2026-01-12: runs/detail.html template expects artifact.cid
but the route provides artifact.hash, causing UndefinedError.
@@ -9,6 +9,33 @@ import pytest
from pathlib import Path
class TestCacheNotFoundTemplate:
"""Tests for cache/not_found.html template."""
def test_template_uses_cid_not_content_hash(self) -> None:
"""
Regression test: not_found.html must use 'cid' variable.
Bug: Template used 'content_hash' but route passes 'cid'.
Fix: Changed template to use 'cid'.
"""
template_path = Path('/home/giles/art/art-celery/app/templates/cache/not_found.html')
content = template_path.read_text()
assert 'cid' in content, "Template should use 'cid' variable"
assert 'content_hash' not in content, \
"Template should not use 'content_hash' (route passes 'cid')"
def test_route_passes_cid_to_template(self) -> None:
"""Verify route passes 'cid' variable to not_found template."""
router_path = Path('/home/giles/art/art-celery/app/routers/cache.py')
content = router_path.read_text()
# Find the render call for not_found.html
assert 'cid=cid' in content, \
"Route should pass cid=cid to not_found.html template"
class TestArtifactDataStructure:
"""Tests for artifact dict keys matching template expectations."""