Files
computer-playbook/tests/unit/cli/meta/ci/test_guide_select.py
T
kevinveenbirkenbachandClaude Fable 5 eacaa4a53b fix(ci): honor tests.yml skip in guide role pool
guide_select built its random pool from invokable + lifecycle only, so
the Guide job could pick roles whose meta/tests.yml declares every
deploy mode untestable (svc-storage-nfs-client, which hard-asserts a
reachable NFS server). Filter the pool by the role's declared skip for
its guide mode; a malformed tests.yml now fails selection loudly
instead of being silently ignored.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-27 04:42:31 +02:00

54 lines
1.7 KiB
Python

from __future__ import annotations
import textwrap
import unittest
from pathlib import Path
from tempfile import TemporaryDirectory
from cli.meta.ci import guide_select
from utils.cache.files import PROJECT_ROOT
from utils.roles.mapping import ROLE_FILE_META_TESTS
from utils.roles.meta_lookup import MetaServicesShapeError, get_role_test_skips
class GuideModeTests(unittest.TestCase):
def test_role_without_stack_deploys_in_host_mode(self):
self.assertEqual(
guide_select._guide_mode(PROJECT_ROOT / "roles" / "svc-storage-nfs-client"),
"host",
)
def test_role_with_stack_deploys_in_compose_mode(self):
self.assertEqual(
guide_select._guide_mode(PROJECT_ROOT / "roles" / "web-app-yourls"),
"compose",
)
class TestableRolesTests(unittest.TestCase):
def test_pool_excludes_roles_whose_guide_mode_is_skipped(self):
pool = guide_select._testable_roles()
self.assertNotIn("svc-storage-nfs-client", pool)
self.assertTrue(pool)
def test_malformed_tests_yml_fails_selection_loudly(self):
with TemporaryDirectory() as tmp:
role_dir = Path(tmp) / "web-app-broken"
tests_path = role_dir / ROLE_FILE_META_TESTS
tests_path.parent.mkdir(parents=True)
tests_path.write_text(
textwrap.dedent(
"""
---
skip: not-a-list
"""
),
encoding="utf-8",
)
with self.assertRaises(MetaServicesShapeError):
get_role_test_skips(role_dir, role_name=role_dir.name)
if __name__ == "__main__":
unittest.main()