Commit remaining workspace changes

This commit is contained in:
2026-03-13 11:45:06 +03:00
parent 36742cd20c
commit 03a90f58bd
8 changed files with 537 additions and 16 deletions

View File

@@ -9,6 +9,7 @@
import os
import sys
import curses
import json
from unittest import mock
from unittest.mock import MagicMock, patch
@@ -152,4 +153,71 @@ def test_tui_clear_history_f7(mock_curses_module, mock_stdscr: MagicMock):
assert len(app.checks_progress) == 0
@patch("src.scripts.clean_release_tui.curses")
def test_tui_real_mode_bootstrap_imports_artifacts_catalog(
mock_curses_module,
mock_stdscr: MagicMock,
tmp_path,
):
"""
@TEST_CONTRACT: bootstrap.json + artifacts.json -> candidate PREPARED with imported artifacts
"""
mock_curses_module.KEY_F10 = curses.KEY_F10
mock_curses_module.color_pair.side_effect = lambda x: x
mock_curses_module.A_BOLD = 0
bootstrap_path = tmp_path / "bootstrap.json"
artifacts_path = tmp_path / "artifacts.json"
bootstrap_path.write_text(
json.dumps(
{
"candidate_id": "real-candidate-1",
"version": "1.0.0",
"source_snapshot_ref": "git:release/1",
"created_by": "operator",
"allowed_hosts": ["repo.intra.company.local"],
}
),
encoding="utf-8",
)
artifacts_path.write_text(
json.dumps(
{
"artifacts": [
{
"id": "artifact-1",
"path": "backend/dist/package.tar.gz",
"sha256": "deadbeef",
"size": 1024,
"category": "core",
"source_uri": "https://repo.intra.company.local/releases/package.tar.gz",
"source_host": "repo.intra.company.local",
}
]
}
),
encoding="utf-8",
)
with mock.patch.dict(
os.environ,
{
"CLEAN_TUI_MODE": "real",
"CLEAN_TUI_BOOTSTRAP_JSON": str(bootstrap_path),
"CLEAN_TUI_ARTIFACTS_JSON": str(artifacts_path),
},
clear=False,
):
app = CleanReleaseTUI(mock_stdscr)
candidate = app.repo.get_candidate("real-candidate-1")
artifacts = app.repo.get_artifacts_by_candidate("real-candidate-1")
assert candidate is not None
assert candidate.status == "PREPARED"
assert len(artifacts) == 1
assert artifacts[0].path == "backend/dist/package.tar.gz"
assert artifacts[0].detected_category == "core"
# [/DEF:backend.tests.scripts.test_clean_release_tui:Module]