Files
computer-playbook/tests/unit/cli/meta/test_graph.py
T
kevinveenbirkenbachandClaude Opus 5 5137465c6f style: delete every comment the comments-valid policy rejects
3529 invalid comments in 528 files, grandfathered in while the linter
only saw the working-tree diff. Removal ran through the linter's own
collectors, so detection and deletion cannot drift: a comment whose
opener line is blank before it and whose closer line is blank after it
loses all its lines, anything else loses only the comment region, and a
line left holding a bare delimiter goes with it.

Five files keep their comments behind a nocheck marker instead. Four are
upstream configs whose inline docs are upstream's own (mautrix, systemd
journald, nextcloud-oidc-login, MediaWiki). In littlejs the
commented-out entries ARE the deactivation mechanism for an example
tile, so deleting them would delete configuration.

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

58 lines
1.8 KiB
Python

import shutil
import tempfile
import unittest
from pathlib import Path
from cli.build import graph
from utils.cache.yaml import dump_yaml
from utils.roles.mapping import ROLE_FILE_META_MAIN, ROLE_FILE_TASKS_MAIN
class TestGraphLogic(unittest.TestCase):
def setUp(self):
self.temp_dir = tempfile.mkdtemp()
self.role_name = "role_a"
self.role_path = str(Path(self.temp_dir) / self.role_name)
Path(str(Path(self.role_path) / "meta")).mkdir(parents=True)
Path(str(Path(self.role_path) / "tasks")).mkdir(parents=True)
dump_yaml(
str(Path(self.role_path) / ROLE_FILE_META_MAIN),
{
"galaxy_info": {"author": "tester", "run_after": []},
"dependencies": [],
},
)
dump_yaml(
str(Path(self.role_path) / ROLE_FILE_TASKS_MAIN),
[
{"include_role": "some_other_role"},
{"import_role": {"name": "another_role"}},
],
)
def tearDown(self):
shutil.rmtree(self.temp_dir)
def test_load_meta_returns_dict(self):
meta_path = graph.find_role_meta(self.temp_dir, self.role_name)
meta = graph.load_meta(meta_path)
self.assertIsInstance(meta, dict)
self.assertIn("galaxy_info", meta)
def test_load_tasks_include_role(self):
task_path = graph.find_role_tasks(self.temp_dir, self.role_name)
includes = graph.load_tasks(task_path, "include_role")
self.assertIn("some_other_role", includes)
def test_build_mappings_structure(self):
result = graph.build_mappings(self.role_name, self.temp_dir, max_depth=1)
self.assertIsInstance(result, dict)
for key in graph.ALL_KEYS:
self.assertIn(key, result)
if __name__ == "__main__":
unittest.main()