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

Functions

Path _write (Path path, dict data)
 test_get_debug_domain_map_v2_not_legacy ()
 test_get_debug_domain_map_v1_is_legacy ()
 test_get_debug_domain_map_short_form_normalised ()
 test_migrate_config_upgrades_v1_to_v2 (Path tmp_path)
 test_migrate_config_idempotent_on_v2 (Path tmp_path)
 test_migrate_config_dry_run_never_writes (Path tmp_path)
 test_validate_config_warns_on_legacy_schema (Path tmp_path)
 test_cli_migrate_config_round_trip (Path tmp_path)

Variables

dict _LEGACY_FULL
dict _LEGACY_SHORT = {"domains": {"TEST": 2}}
dict _V2_FULL

Detailed Description

Purpose
-------
OI-508 / FS-515 regression coverage — ``debug_config.json`` schema
bridge. :func:`_get_debug_domain_map` must normalise both the legacy v1
``domains:`` and the current v2 ``DEBUG_LEVELS:`` shape into a single
map shape; :func:`migrate_config` must upgrade v1 -> v2 in-place with a
``.bk`` backup and be idempotent on already-v2 files. The
``oct diag migrate-config`` CLI command must expose the same behaviour
and print a helpful summary.

Responsibilities
----------------
- Verify legacy v1 ``domains:`` config normalises into v2 ``DEBUG_LEVELS``.
- Verify ``migrate-config`` creates a ``.bk`` backup and is idempotent.
- Verify ``validate-config`` emits a WARNING on legacy schema with a
  ``migrate-config`` hint.

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

Contracts
---------
- Legacy ``domains:`` config normalises into a v2 ``DEBUG_LEVELS`` map.
- Running migrate-config writes ``<path>.bk`` with the original content.
- Running migrate-config twice is a no-op (no backup clobber).
- ``validate-config`` emits a WARNING (not ERROR) on legacy schema and
  references the ``migrate-config`` hint.

Function Documentation

◆ _write()

Path tests_diag.test_migrate_config._write ( Path path,
dict data )
protected

Definition at line 77 of file test_migrate_config.py.

Here is the caller graph for this function:

◆ test_cli_migrate_config_round_trip()

tests_diag.test_migrate_config.test_cli_migrate_config_round_trip ( Path tmp_path)
OI-508: ``oct diag migrate-config PATH`` migrates an arbitrary file.

Definition at line 149 of file test_migrate_config.py.

Here is the call graph for this function:

◆ test_get_debug_domain_map_short_form_normalised()

tests_diag.test_migrate_config.test_get_debug_domain_map_short_form_normalised ( )
v1 short form ``{"TEST": 2}`` → ``{"TEST": {"level": 2, "color": "default"}}``.

Definition at line 97 of file test_migrate_config.py.

◆ test_get_debug_domain_map_v1_is_legacy()

tests_diag.test_migrate_config.test_get_debug_domain_map_v1_is_legacy ( )
v1 ``domains`` → is_legacy is True; shape matches v2.

Definition at line 89 of file test_migrate_config.py.

◆ test_get_debug_domain_map_v2_not_legacy()

tests_diag.test_migrate_config.test_get_debug_domain_map_v2_not_legacy ( )
v2 ``DEBUG_LEVELS`` → is_legacy is False.

Definition at line 82 of file test_migrate_config.py.

◆ test_migrate_config_dry_run_never_writes()

tests_diag.test_migrate_config.test_migrate_config_dry_run_never_writes ( Path tmp_path)
OI-508: dry_run returns the target shape without touching disk.

Definition at line 128 of file test_migrate_config.py.

Here is the call graph for this function:

◆ test_migrate_config_idempotent_on_v2()

tests_diag.test_migrate_config.test_migrate_config_idempotent_on_v2 ( Path tmp_path)
OI-508: running migrate on an already-v2 file is a no-op.

Definition at line 118 of file test_migrate_config.py.

Here is the call graph for this function:

◆ test_migrate_config_upgrades_v1_to_v2()

tests_diag.test_migrate_config.test_migrate_config_upgrades_v1_to_v2 ( Path tmp_path)
OI-508: migrate writes v2 schema in-place and creates .bk backup.

Definition at line 104 of file test_migrate_config.py.

Here is the call graph for this function:

◆ test_validate_config_warns_on_legacy_schema()

tests_diag.test_migrate_config.test_validate_config_warns_on_legacy_schema ( Path tmp_path)
OI-508: legacy schema → WARNING with migration hint; no hard ERROR.

Definition at line 138 of file test_migrate_config.py.

Here is the call graph for this function:

Variable Documentation

◆ _LEGACY_FULL

dict tests_diag.test_migrate_config._LEGACY_FULL
protected
Initial value:
1= {
2 "_schema_version": "1.0",
3 "domains": {
4 "ALPHA": {"level": 2, "color": "red"},
5 "BETA": {"level": 3, "color": "blue"},
6 },
7 "global_settings": {"mode": "dev"},
8}

Definition at line 57 of file test_migrate_config.py.

◆ _LEGACY_SHORT

dict tests_diag.test_migrate_config._LEGACY_SHORT = {"domains": {"TEST": 2}}
protected

Definition at line 66 of file test_migrate_config.py.

◆ _V2_FULL

dict tests_diag.test_migrate_config._V2_FULL
protected
Initial value:
1= {
2 "_schema_version": "2.0",
3 "DEBUG_LEVELS": {
4 "ALPHA": {"level": 2, "color": "red"},
5 },
6 "global_settings": {"mode": "dev"},
7}

Definition at line 68 of file test_migrate_config.py.