|
Option C Tools
|
Functions | |
| bool | _git_available () |
| subprocess.CompletedProcess | _git (Path repo, *str args, bool check=True) |
| None | commit_file (Path repo, str name, str content, str message="add file") |
| Path | temp_git_project (Path tmp_path) |
| make_compliant_py (Path temp_git_project) | |
| make_noncompliant_py (Path temp_git_project) | |
Variables | |
| _COMPLIANT_TEMPLATE = textwrap.dedent() | |
| _NONCOMPLIANT_MISSING_HEADER = textwrap.dedent() | |
| _NONCOMPLIANT_MISSING_DOCSTRING = textwrap.dedent() | |
| _NONCOMPLIANT_HARDCODED_SECRET = textwrap.dedent() | |
| _NONCOMPLIANT_FORMAT_ERROR = textwrap.dedent() | |
Purpose
-------
Shared fixtures for the ``oct git`` integration tests (Phase 4B).
Provides pre-seeded git repositories with Option C project structure
so that ``oct git status`` and ``oct git check`` can be tested against
realistic scenarios.
Responsibilities
----------------
- ``temp_git_project``: a real git repo with minimal Option C structure.
- ``make_compliant_py``: factory writing a fully-compliant Python file.
- ``make_noncompliant_py``: factory writing a file with a chosen violation.
- ``commit_file``: helper to stage + commit a file.
Diagnostics
-----------
Domain: GIT-TESTS
Levels:
L2 — fixture lifecycle
L3 — fixture setup details
L4 — deep tracing
Contracts
---------
- ``temp_git_project`` always returns a directory that is a real git
working tree with ``user.name`` / ``user.email`` pre-configured and
at least one commit (HEAD exists).
- All fixtures create files under ``tmp_path`` so they are automatically
cleaned up by pytest.
|
protected |
Run a git command inside *repo*.
Definition at line 56 of file conftest.py.
|
protected |
| None tests_git.conftest.commit_file | ( | Path | repo, |
| str | name, | ||
| str | content, | ||
| str | message = "add file" ) |
Write a file, stage it, and commit it.
Definition at line 67 of file conftest.py.
| tests_git.conftest.make_compliant_py | ( | Path | temp_git_project | ) |
Factory: write a compliant Python file and return its Path.
Usage::
path = make_compliant_py("src/good.py")
Definition at line 273 of file conftest.py.
| tests_git.conftest.make_noncompliant_py | ( | Path | temp_git_project | ) |
Factory: write a noncompliant Python file with a chosen violation.
Usage::
path = make_noncompliant_py("src/bad.py", "missing_header")
Supported violations:
- ``"missing_header"``
- ``"missing_docstring"``
- ``"hardcoded_secret"``
- ``"format_error"``
Definition at line 304 of file conftest.py.
| Path tests_git.conftest.temp_git_project | ( | Path | tmp_path | ) |
Create a minimal Option C project inside a real git repo.
Directory structure::
<root>/
├── .octrc.json
├── debug_config.json
├── docs/
│ └── ARCHITECTURE.md
├── logs/
├── oc_diagnostics/
├── src/
└── tests/
The repo has one initial commit so HEAD exists, and
``user.name``/``user.email`` are configured.
Definition at line 198 of file conftest.py.
|
protected |
Definition at line 83 of file conftest.py.
|
protected |
Definition at line 163 of file conftest.py.
|
protected |
Definition at line 134 of file conftest.py.
|
protected |
Definition at line 125 of file conftest.py.
|
protected |
Definition at line 118 of file conftest.py.