Option C Tools
Loading...
Searching...
No Matches
test_octrc_template.py
Go to the documentation of this file.
1
#!/usr/bin/env python3
2
# -*- coding: utf-8 -*-
3
# tests/tests_scaffold/test_octrc_template.py
4
5
"""
6
Purpose
7
-------
8
OI-530 regression coverage — the scaffolded ``.octrc.json`` must ship
9
with a live ``linter.profile`` default plus a discoverable (but inert)
10
``_git_example`` stanza so new projects inherit sensible defaults and
11
can copy-paste branch protection into place without reading docs.
12
13
Responsibilities
14
----------------
15
- ``linter.profile == "compact"`` after scaffold.
16
- ``_git_example`` is present and documents ``protected_branches`` +
17
``branch_profile_map``.
18
- :func:`oct.core.octrc.load_octrc_safe` round-trips the template without
19
dropping the underscore-prefixed example key.
20
21
Diagnostics
22
-----------
23
Domain: SCAFFOLD-TESTS
24
Levels:
25
L2 — test lifecycle
26
L3 — assertion details
27
L4 — deep tracing
28
29
Contracts
30
---------
31
- All scaffold operations write to ``tmp_path``; no real project
32
directories are created.
33
"""
34
35
from
__future__
import
annotations
36
37
import
json
38
from
pathlib
import
Path
39
40
from
oct.core.octrc
import
load_octrc_safe
41
from
oct.scaffold
import
run_scaffold
42
43
44
def
test_octrc_template_has_linter_profile
(tmp_path: Path):
45
run_scaffold(
"demo"
, tmp_path, include_venv=
False
)
46
octrc = tmp_path /
"demo"
/
".option_c"
/
"octrc.json"
47
data = json.loads(octrc.read_text(encoding=
"utf-8"
))
48
49
assert
data[
"linter"
][
"profile"
] ==
"compact"
50
51
52
def
test_octrc_template_has_git_example
(tmp_path: Path):
53
run_scaffold(
"demo"
, tmp_path, include_venv=
False
)
54
octrc = tmp_path /
"demo"
/
".option_c"
/
"octrc.json"
55
data = json.loads(octrc.read_text(encoding=
"utf-8"
))
56
57
example = data.get(
"_git_example"
)
58
assert
isinstance(example, dict)
59
assert
"main"
in
example[
"protected_branches"
]
60
assert
example[
"branch_profile_map"
][
"main"
] ==
"strict"
61
62
63
def
test_octrc_template_round_trips_through_safe_loader
(tmp_path: Path):
64
run_scaffold(
"demo"
, tmp_path, include_venv=
False
)
65
project = tmp_path /
"demo"
66
67
data = load_octrc_safe(project)
68
69
# The underscore key is preserved (the loader does not strip it).
70
# OI-530: its purpose is discoverability; consumers never read it.
71
assert
"_git_example"
in
data
72
assert
data[
"linter"
][
"profile"
] ==
"compact"
oct.scaffold
Definition
__init__.py:1
tests_scaffold.test_octrc_template.test_octrc_template_has_git_example
test_octrc_template_has_git_example(Path tmp_path)
Definition
test_octrc_template.py:52
tests_scaffold.test_octrc_template.test_octrc_template_round_trips_through_safe_loader
test_octrc_template_round_trips_through_safe_loader(Path tmp_path)
Definition
test_octrc_template.py:63
tests_scaffold.test_octrc_template.test_octrc_template_has_linter_profile
test_octrc_template_has_linter_profile(Path tmp_path)
Definition
test_octrc_template.py:44
tests
tests_scaffold
test_octrc_template.py
Generated by
1.15.0