Option C Tools
Loading...
Searching...
No Matches
tests_diag.test_set_level_safety Namespace Reference

Functions

Path _write_config (Path root, dict data)
 test_dry_run_does_not_write_or_backup (tmp_path)
 test_write_creates_backup_with_original_text (tmp_path)
 test_restore_config_round_trips_backup (tmp_path)
 test_restore_config_without_backup_raises (tmp_path)
 test_backup_is_overwritten_with_pre_edit_text_on_second_write (tmp_path)
 test_cli_set_level_dry_run_does_not_touch_files (tmp_path, monkeypatch)
 test_cli_restore_command_round_trips (tmp_path, monkeypatch)

Variables

dict _V2_CONFIG

Detailed Description

Purpose
-------
OI-528 regression coverage — :func:`oct.diag.oct_diag.set_level` and the
paired :func:`restore_config` helper must provide safe in-place edits of
``debug_config.json``. A bad level write can brick diagnostics, so the
operation is backed by a ``<path>.bk`` sidecar and a ``--dry-run`` flag
that short-circuits both writes.

Responsibilities
----------------
- ``--dry-run`` never writes to the config or creates ``.bk``.
- A real write creates ``<path>.bk`` containing the original text.
- :func:`restore_config` round-trips the backup back onto the config.
- Calling :func:`restore_config` with no backup raises cleanly.
- Re-running ``set_level`` overwrites ``.bk`` with the pre-edit text.

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

Contracts
---------
- All config writes and backups use ``tmp_path``; no real
  ``debug_config.json`` is modified.

Function Documentation

◆ _write_config()

Path tests_diag.test_set_level_safety._write_config ( Path root,
dict data )
protected

Definition at line 58 of file test_set_level_safety.py.

Here is the caller graph for this function:

◆ test_backup_is_overwritten_with_pre_edit_text_on_second_write()

tests_diag.test_set_level_safety.test_backup_is_overwritten_with_pre_edit_text_on_second_write ( tmp_path)

Definition at line 113 of file test_set_level_safety.py.

Here is the call graph for this function:

◆ test_cli_restore_command_round_trips()

tests_diag.test_set_level_safety.test_cli_restore_command_round_trips ( tmp_path,
monkeypatch )

Definition at line 138 of file test_set_level_safety.py.

Here is the call graph for this function:

◆ test_cli_set_level_dry_run_does_not_touch_files()

tests_diag.test_set_level_safety.test_cli_set_level_dry_run_does_not_touch_files ( tmp_path,
monkeypatch )

Definition at line 124 of file test_set_level_safety.py.

Here is the call graph for this function:

◆ test_dry_run_does_not_write_or_backup()

tests_diag.test_set_level_safety.test_dry_run_does_not_write_or_backup ( tmp_path)

Definition at line 70 of file test_set_level_safety.py.

Here is the call graph for this function:

◆ test_restore_config_round_trips_backup()

tests_diag.test_set_level_safety.test_restore_config_round_trips_backup ( tmp_path)

Definition at line 94 of file test_set_level_safety.py.

Here is the call graph for this function:

◆ test_restore_config_without_backup_raises()

tests_diag.test_set_level_safety.test_restore_config_without_backup_raises ( tmp_path)

Definition at line 106 of file test_set_level_safety.py.

Here is the call graph for this function:

◆ test_write_creates_backup_with_original_text()

tests_diag.test_set_level_safety.test_write_creates_backup_with_original_text ( tmp_path)

Definition at line 81 of file test_set_level_safety.py.

Here is the call graph for this function:

Variable Documentation

◆ _V2_CONFIG

dict tests_diag.test_set_level_safety._V2_CONFIG
protected
Initial value:
1= {
2 "_schema_version": "2.0",
3 "DEBUG_LEVELS": {
4 "GENERAL": {"level": 1, "color": "default"},
5 "NET": {"level": 2, "color": "blue"},
6 },
7 "global_settings": {"mode": "dev"},
8}

Definition at line 48 of file test_set_level_safety.py.