Option C Tools
Loading...
Searching...
No Matches
tests_git.conftest Namespace Reference

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()

Detailed Description

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.

Function Documentation

◆ _git()

subprocess.CompletedProcess tests_git.conftest._git ( Path repo,
*str args,
bool check = True )
protected
Run a git command inside *repo*.

Definition at line 56 of file conftest.py.

Here is the caller graph for this function:

◆ _git_available()

bool tests_git.conftest._git_available ( )
protected

Definition at line 52 of file conftest.py.

Here is the caller graph for this function:

◆ commit_file()

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.

Here is the call graph for this function:

◆ make_compliant_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.

◆ make_noncompliant_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.

◆ temp_git_project()

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.

Here is the call graph for this function:

Variable Documentation

◆ _COMPLIANT_TEMPLATE

tests_git.conftest._COMPLIANT_TEMPLATE = textwrap.dedent()
protected

Definition at line 83 of file conftest.py.

◆ _NONCOMPLIANT_FORMAT_ERROR

tests_git.conftest._NONCOMPLIANT_FORMAT_ERROR = textwrap.dedent()
protected

Definition at line 163 of file conftest.py.

◆ _NONCOMPLIANT_HARDCODED_SECRET

tests_git.conftest._NONCOMPLIANT_HARDCODED_SECRET = textwrap.dedent()
protected

Definition at line 134 of file conftest.py.

◆ _NONCOMPLIANT_MISSING_DOCSTRING

tests_git.conftest._NONCOMPLIANT_MISSING_DOCSTRING = textwrap.dedent()
protected

Definition at line 125 of file conftest.py.

◆ _NONCOMPLIANT_MISSING_HEADER

tests_git.conftest._NONCOMPLIANT_MISSING_HEADER = textwrap.dedent()
protected

Definition at line 118 of file conftest.py.