Option C Tools
Loading...
Searching...
No Matches
test_option_c_layout.py
Go to the documentation of this file.
1#!/usr/bin/env python3
2# -*- coding: utf-8 -*-
3# tests/tests_scaffold/test_option_c_layout.py
4
5"""
6Purpose
7-------
8FS-539 regression coverage — :func:`oct.scaffold.run_scaffold` must emit
9the canonical ``.option_c/`` dotdir layout (not the legacy root-level
10``.octrc.json`` + ``oc_diagnostics/debug_config.json`` + ``logs/``
11layout) and stamp a ``stage="compliant"`` ``oc_status.json`` so newly
12scaffolded projects are born migrated.
13
14Responsibilities
15----------------
16- ``.option_c/`` + ``.option_c/logs/`` + ``.option_c/cache/`` exist.
17- ``.option_c/oc_status.json`` is a well-formed v1 schema blob with
18 every pillar enabled.
19- Legacy paths (``.octrc.json``, ``oc_diagnostics/``, root-level
20 ``logs/``) are absent — the scaffold does not dual-write.
21
22Diagnostics
23-----------
24Domain: SCAFFOLD-TESTS
25 Levels:
26 L2 — test lifecycle
27 L3 — assertion details
28 L4 — deep tracing
29
30Contracts
31---------
32- All scaffold operations write to ``tmp_path``; no real project
33 directories are created.
34"""
35
36from __future__ import annotations
37
38import json
39from pathlib import Path
40
41from oct.core.option_c_dir import VALID_STAGES, load_oc_status
42from oct.scaffold import run_scaffold
43
44
46 run_scaffold("demo", tmp_path, include_venv=False)
47 project = tmp_path / "demo"
48
49 assert (project / ".option_c").is_dir()
50 assert (project / ".option_c" / "logs").is_dir()
51 assert (project / ".option_c" / "cache").is_dir()
52 assert (project / ".option_c" / "octrc.json").is_file()
53 assert (project / ".option_c" / "debug_config.json").is_file()
54 assert (project / ".option_c" / "oc_status.json").is_file()
55
56
58 run_scaffold("demo", tmp_path, include_venv=False)
59 project = tmp_path / "demo"
60
61 status = load_oc_status(project)
62 assert status is not None
63 assert status.stage == "compliant"
64 assert status.stage in VALID_STAGES
65 for pillar in ("linter", "diagnostics", "git", "docs", "tests", "scaffold"):
66 assert pillar in status.pillars, pillar
67 assert status.pillars[pillar]["enabled"] is True
68 # Fresh scaffold — nothing migrated in from legacy paths.
69 assert status.migrated_from == {}
70
71
73 run_scaffold("demo", tmp_path, include_venv=False)
74 raw = json.loads(
75 (tmp_path / "demo" / ".option_c" / "oc_status.json").read_text(
76 encoding="utf-8",
77 )
78 )
79 assert raw["_schema_version"] == "1.0"
80
81
83 run_scaffold("demo", tmp_path, include_venv=False)
84 project = tmp_path / "demo"
85
86 # FS-539: the legacy layout is intentionally not dual-written —
87 # the scaffold is the migrated-from-birth form.
88 assert not (project / ".octrc.json").exists()
89 assert not (project / "oc_diagnostics").exists()
90 assert not (project / "logs").exists()
test_scaffold_oc_status_is_compliant_with_all_pillars(Path tmp_path)