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

Classes

class  TestRedactArgs
class  TestAuditRecordSerialisation
class  TestAuditLoggerWrite
class  TestSizeRotation
class  TestCountRotation
class  TestResolveProjectRoot
class  TestAuditedDecorator

Functions

Path project_root (Path tmp_path)
 make_record ()

Detailed Description

Purpose
-------
Unit tests for :mod:`oct.git.audit` — the rotating JSONL audit logger
and the :func:`audited` decorator for Phase 4B ``oct git`` commands
(G-B5 / G-B6).

Responsibilities
----------------
- Verify :class:`AuditRecord` serialises to JSONL as one-object-per-line.
- Verify the size-rotation threshold is honoured: the very first write
  that lifts a file at/above :data:`AUDIT_MAX_SIZE_BYTES` goes into a
  fresh file.
- Verify the count-rotation threshold: no more than
  :data:`AUDIT_MAX_FILES` files live in ``logs/`` at once.
- Verify credential redaction applies to every ``args`` entry.
- Verify :func:`audited` writes a row on both success and exception,
  never swallows exceptions from the wrapped function, and records
  ``duration_ms`` monotonically.

Diagnostics
-----------
Domain: GIT-TESTS
Levels:
    L2 — test lifecycle
    L3 — assertion details
    L4 — deep tracing

Contracts
---------
- No real git subprocess, no real Click group — the decorator is tested
  against a minimal SimpleNamespace stand-in for ``ctx``.
- Every test uses a ``tmp_path`` subdirectory as its project root so
  the real ``logs/`` directory is never touched.

Function Documentation

◆ make_record()

tests_git.test_audit.make_record ( )
Factory returning a minimal populated :class:`AuditRecord`.

Definition at line 77 of file test_audit.py.

Here is the caller graph for this function:

◆ project_root()

Path tests_git.test_audit.project_root ( Path tmp_path)
A throwaway project root. The logs dir is NOT pre-created so we
can assert the logger materialises it on demand.

Definition at line 68 of file test_audit.py.