Option C oc_diagnostics
Loading...
Searching...
No Matches
test_id_instrumentation Namespace Reference

Functions

 test_structural_id_protection ()
 test_instrument_ids_basic ()
 test_dict_id_not_rewritten ()
 test_no_id_component_unchanged ()
 test_max_depth_limit ()
 test_nested_children_traversal ()
 test_additional_structural_prefixes ()
 test_additional_structural_exact ()

Variables

 _REPO_ROOT = os.path.normpath(os.path.join(os.path.dirname(__file__), ".."))
 dash_html = pytest.importorskip("dash.html", reason="Dash not installed")
 html = dash_html

Detailed Description

Regression Tests — id_instrumentation
=======================================

Purpose
-------
Verify the full behaviour of ``id_instrumentation``: structural-ID protection,
dict-ID passthrough, depth-limit guarding, recursive children traversal, and
project-defined custom structural ID extensions.

Responsibilities
----------------
- Confirm ``is_structural_id()`` correctly classifies built-in structural and
  non-structural IDs.
- Confirm ``instrument_ids()`` rewrites non-structural string IDs to
  ``{"event": "<id>"}``.
- Confirm dict IDs are never rewritten.
- Confirm components without an ``id`` attribute are returned unchanged.
- Confirm recursion stops at ``MAX_INSTRUMENT_DEPTH`` without raising.
- Confirm nested children are instrumented recursively.
- Confirm ``ADDITIONAL_STRUCTURAL_PREFIXES`` prevents instrumentation.
- Confirm ``ADDITIONAL_STRUCTURAL_EXACT`` prevents instrumentation.

Diagnostics
-----------
Domain: TEST
Levels:
    L2 — lifecycle
    L3 — semantic details
    L4 — deep tracing

Contracts
---------
- All Dash-dependent tests are skipped automatically when Dash is not installed.
- Must not permanently modify oc_diagnostics global state.
- Must restore all patched globals in finally blocks.
- Must not start servers or require network access.
- Must run deterministically across repeated invocations.

Function Documentation

◆ test_additional_structural_exact()

test_id_instrumentation.test_additional_structural_exact ( )
ADDITIONAL_STRUCTURAL_EXACT prevents ID rewriting for exact-match IDs.

Definition at line 243 of file test_id_instrumentation.py.

◆ test_additional_structural_prefixes()

test_id_instrumentation.test_additional_structural_prefixes ( )
ADDITIONAL_STRUCTURAL_PREFIXES prevents ID rewriting for matching components.

Definition at line 219 of file test_id_instrumentation.py.

◆ test_dict_id_not_rewritten()

test_id_instrumentation.test_dict_id_not_rewritten ( )
Components with dict IDs are returned unchanged — no double-wrapping.

Definition at line 123 of file test_id_instrumentation.py.

◆ test_instrument_ids_basic()

test_id_instrumentation.test_instrument_ids_basic ( )
instrument_ids() rewrites a non-structural string ID to {"event": "<id>"}.

Definition at line 102 of file test_id_instrumentation.py.

◆ test_max_depth_limit()

test_id_instrumentation.test_max_depth_limit ( )
instrument_ids() stops recursion at MAX_INSTRUMENT_DEPTH without RecursionError.

Definition at line 168 of file test_id_instrumentation.py.

◆ test_nested_children_traversal()

test_id_instrumentation.test_nested_children_traversal ( )
instrument_ids() recursively instruments children of a component.

Definition at line 194 of file test_id_instrumentation.py.

◆ test_no_id_component_unchanged()

test_id_instrumentation.test_no_id_component_unchanged ( )
Components without an id attribute have their ID left as None.

Definition at line 145 of file test_id_instrumentation.py.

◆ test_structural_id_protection()

test_id_instrumentation.test_structural_id_protection ( )
is_structural_id() correctly classifies structural and non-structural IDs.

Definition at line 74 of file test_id_instrumentation.py.

Variable Documentation

◆ _REPO_ROOT

test_id_instrumentation._REPO_ROOT = os.path.normpath(os.path.join(os.path.dirname(__file__), ".."))
protected

Definition at line 52 of file test_id_instrumentation.py.

◆ dash_html

test_id_instrumentation.dash_html = pytest.importorskip("dash.html", reason="Dash not installed")

Definition at line 59 of file test_id_instrumentation.py.

◆ html

test_id_instrumentation.html = dash_html

Definition at line 60 of file test_id_instrumentation.py.