|
Option C Tools
|
Classes | |
| class | _FakeCompleted |
Variables | |
| bool | _CAN_SYMLINK = _platform_can_symlink() |
| tuple | _SYMLINK_SKIP_REASON |
| str | _TOKEN_URL = "https://oauth2:ghp_SUPERSECRET@github.com/foo/bar.git" |
Purpose
-------
Validate the V4.0 Phase 4A Git integration foundation in
``oct.core.git``: exception hierarchy, subprocess discipline,
credential redaction, and the 11 read-only state query functions.
Responsibilities
----------------
- Confirm the ``GitError`` hierarchy (G-A1).
- Confirm ``git_run`` enforces argv-only, timeout, text mode, utf-8
with ``errors="replace"``, and translates subprocess failures to
``GitNotFoundError`` / ``GitTimeoutError`` / ``GitCommandError``
(G-A2).
- Confirm every query function behaves correctly against a real git
repo, raising the right error on missing repo / missing binary
(G-A3).
- Confirm path-escape filtering in ``git_changed_files`` and
``git_staged_files`` (G-A3 + G-A4 defense-in-depth).
- Confirm ``_redact_git_url`` scrubs http(s) credentials while leaving
SSH URLs intact (G-A5).
- Confirm ``_git_changed_files`` shim in the linter continues to
return ``[]`` on all ``GitError`` subtypes (G-A7).
Diagnostics
-----------
Domain: CORE-TESTS
Levels:
L2 — test lifecycle
L3 — per-case setup
L4 — fine-grained assertions
Contracts
---------
- Tests never write outside of ``tmp_path`` / pytest-managed temp dirs.
- Tests that require a real ``git`` binary are skipped via the
``git_repo`` fixture when git is missing.
- Symlink tests skip when the platform cannot create symlinks.
|
protected |
Probe whether this process can create a real OS symlink. Equivalent to the session-scoped ``can_symlink`` fixture in ``tests_core/conftest.py`` but evaluated at module import so the result is usable in ``@pytest.mark.skipif`` decorators (which run at collection time and cannot consume runtime fixtures). On Windows without admin elevation or developer-mode this returns ``False``; on POSIX it returns ``True`` unless the filesystem refuses the syscall (e.g. some FAT mounts).
Definition at line 54 of file test_git.py.
| tests_core.test_git.test_current_branch_returns_name | ( | git_repo | ) |
Definition at line 388 of file test_git.py.
| tests_core.test_git.test_get_repo_root_raises_not_a_repo | ( | tmp_path | ) |
Definition at line 383 of file test_git.py.
| tests_core.test_git.test_get_repo_root_returns_absolute_path | ( | git_repo | ) |
Definition at line 379 of file test_git.py.
| tests_core.test_git.test_git_changed_files_empty_on_clean_repo | ( | git_repo | ) |
Definition at line 449 of file test_git.py.
| tests_core.test_git.test_git_changed_files_filters_by_extension | ( | git_repo | ) |
Definition at line 441 of file test_git.py.
| tests_core.test_git.test_git_changed_files_filters_out_path_escapes | ( | git_repo, | |
| tmp_path ) |
``git_changed_files`` must filter symlinks that escape the repo. Skipped on platforms without symlink capability — this is an environmental constraint, not a defect in the tested behaviour.
Definition at line 555 of file test_git.py.
| tests_core.test_git.test_git_changed_files_returns_absolute_paths | ( | git_repo | ) |
Definition at line 433 of file test_git.py.
| tests_core.test_git.test_git_command_error_preserves_context | ( | ) |
Definition at line 120 of file test_git.py.
| tests_core.test_git.test_git_command_error_str_redacts_token_in_argv | ( | ) |
Definition at line 223 of file test_git.py.
| tests_core.test_git.test_git_error_is_base_of_all_subclasses | ( | ) |
Definition at line 113 of file test_git.py.
| tests_core.test_git.test_git_run_dbg_does_not_leak_token | ( | tmp_path, | |
| monkeypatch, | |||
| caplog ) |
_dbg logs argv before the subprocess runs; it must be redacted.
Definition at line 203 of file test_git.py.
| tests_core.test_git.test_git_run_happy_path | ( | tmp_path, | |
| monkeypatch ) |
Definition at line 267 of file test_git.py.
| tests_core.test_git.test_git_run_nocheck_returns_process | ( | tmp_path, | |
| monkeypatch ) |
Definition at line 312 of file test_git.py.
| tests_core.test_git.test_git_run_raises_git_not_found | ( | tmp_path, | |
| monkeypatch ) |
Definition at line 286 of file test_git.py.
| tests_core.test_git.test_git_run_raises_on_nonzero_exit | ( | tmp_path, | |
| monkeypatch ) |
Definition at line 302 of file test_git.py.
| tests_core.test_git.test_git_run_raises_timeout | ( | tmp_path, | |
| monkeypatch ) |
Definition at line 294 of file test_git.py.
| tests_core.test_git.test_git_run_redacts_stderr_on_error | ( | tmp_path, | |
| monkeypatch ) |
Definition at line 320 of file test_git.py.
| tests_core.test_git.test_git_run_redacts_stdout_on_success | ( | tmp_path, | |
| monkeypatch ) |
Definition at line 334 of file test_git.py.
| tests_core.test_git.test_git_run_rejects_non_list_argv | ( | tmp_path | ) |
Definition at line 262 of file test_git.py.
| tests_core.test_git.test_git_staged_files_only_returns_staged | ( | git_repo | ) |
Definition at line 455 of file test_git.py.
| tests_core.test_git.test_has_uncommitted_changes_false_on_clean_repo | ( | git_repo | ) |
Definition at line 411 of file test_git.py.
| tests_core.test_git.test_has_uncommitted_changes_true_after_edit | ( | git_repo | ) |
Definition at line 417 of file test_git.py.
| tests_core.test_git.test_has_untracked_files_false_on_fresh_repo | ( | git_repo | ) |
Definition at line 424 of file test_git.py.
| tests_core.test_git.test_has_untracked_files_true_for_new_file | ( | git_repo | ) |
Definition at line 428 of file test_git.py.
| tests_core.test_git.test_is_detached_head_false_on_branch | ( | git_repo | ) |
Definition at line 394 of file test_git.py.
| tests_core.test_git.test_is_detached_head_true_after_checkout_sha | ( | git_repo | ) |
Definition at line 400 of file test_git.py.
| tests_core.test_git.test_is_git_repo_false_on_any_exception | ( | tmp_path, | |
| monkeypatch ) |
Definition at line 367 of file test_git.py.
| tests_core.test_git.test_is_git_repo_false_outside_repo | ( | tmp_path | ) |
Definition at line 356 of file test_git.py.
| tests_core.test_git.test_is_git_repo_false_when_git_missing | ( | tmp_path, | |
| monkeypatch ) |
Definition at line 360 of file test_git.py.
| tests_core.test_git.test_is_git_repo_true_inside_repo | ( | git_repo | ) |
Definition at line 352 of file test_git.py.
| tests_core.test_git.test_is_within_project_root_false_for_sibling | ( | tmp_path | ) |
Definition at line 527 of file test_git.py.
| tests_core.test_git.test_is_within_project_root_false_for_symlink_escape | ( | tmp_path | ) |
Symlinks pointing outside the project root must not be accepted. Skipped on platforms without symlink capability — this is an environmental constraint, not a defect in the tested behaviour.
Definition at line 539 of file test_git.py.
| tests_core.test_git.test_is_within_project_root_handles_nonexistent_paths | ( | tmp_path | ) |
Definition at line 532 of file test_git.py.
| tests_core.test_git.test_is_within_project_root_true_for_child | ( | tmp_path | ) |
Definition at line 516 of file test_git.py.
| tests_core.test_git.test_is_within_project_root_true_for_self | ( | tmp_path | ) |
Definition at line 523 of file test_git.py.
| tests_core.test_git.test_last_commit_message_empty_on_fresh_repo | ( | git_repo | ) |
Definition at line 482 of file test_git.py.
| tests_core.test_git.test_last_commit_message_returns_subject | ( | git_repo | ) |
Definition at line 486 of file test_git.py.
| tests_core.test_git.test_last_commit_sha_empty_on_fresh_repo | ( | git_repo | ) |
Definition at line 468 of file test_git.py.
| tests_core.test_git.test_last_commit_sha_full_and_short | ( | git_repo | ) |
Definition at line 472 of file test_git.py.
| tests_core.test_git.test_legacy_shim_passes_py_extension_filter | ( | tmp_path, | |
| monkeypatch ) |
Definition at line 609 of file test_git.py.
| tests_core.test_git.test_legacy_shim_returns_empty_on_command_error | ( | tmp_path, | |
| monkeypatch ) |
Definition at line 596 of file test_git.py.
| tests_core.test_git.test_legacy_shim_returns_empty_on_missing_git | ( | tmp_path, | |
| monkeypatch ) |
Definition at line 574 of file test_git.py.
| tests_core.test_git.test_legacy_shim_returns_empty_on_not_a_repo | ( | tmp_path, | |
| monkeypatch ) |
Definition at line 585 of file test_git.py.
| tests_core.test_git.test_redact_argv_noop_for_plain_argv | ( | ) |
Definition at line 198 of file test_git.py.
| tests_core.test_git.test_redact_argv_redacts_url_elements | ( | ) |
Definition at line 190 of file test_git.py.
| tests_core.test_git.test_redact_handles_empty_string | ( | ) |
Definition at line 156 of file test_git.py.
| tests_core.test_git.test_redact_handles_none_safely | ( | ) |
Definition at line 160 of file test_git.py.
| tests_core.test_git.test_redact_multiline_output | ( | ) |
Definition at line 166 of file test_git.py.
| tests_core.test_git.test_redact_preserves_non_url_content | ( | ) |
Definition at line 176 of file test_git.py.
| tests_core.test_git.test_redact_preserves_ssh_urls | ( | ) |
Definition at line 151 of file test_git.py.
| tests_core.test_git.test_redact_strips_http_creds | ( | ) |
Definition at line 138 of file test_git.py.
| tests_core.test_git.test_redact_strips_https_creds | ( | ) |
Definition at line 144 of file test_git.py.
| tests_core.test_git.test_remote_urls_empty_on_fresh_repo | ( | git_repo | ) |
Definition at line 492 of file test_git.py.
| tests_core.test_git.test_remote_urls_redacts_http_creds | ( | git_repo | ) |
Definition at line 496 of file test_git.py.
| tests_core.test_git.test_timeout_message_redacts_token | ( | tmp_path, | |
| monkeypatch ) |
Definition at line 237 of file test_git.py.
|
protected |
Definition at line 76 of file test_git.py.
|
protected |
Definition at line 77 of file test_git.py.
|
protected |
Definition at line 187 of file test_git.py.