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

Functions

 test_apply_instrumentation_no_op ()
 test_apply_list_return ()
 test_apply_tuple_return ()
 test_apply_single_component ()
 test_no_double_wrapping ()

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 — instrumentation_middleware
==============================================

Purpose
-------
Verify the public API of ``instrumentation_middleware``: the no-op contract
when instrumentation is disabled, list/tuple container preservation, single-
component instrumentation, and the double-wrapping prevention guard.

Responsibilities
----------------
- Confirm ``apply_instrumentation()`` returns the component unchanged when
  ``INSTRUMENTATION_ENABLED=False``.
- Confirm list inputs are instrumented element-by-element with the list type
  preserved.
- Confirm tuple inputs are instrumented element-by-element with the tuple type
  preserved.
- Confirm a single component has its string ID rewritten.
- Confirm a component whose ID is already a dict is not double-wrapped.

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

Contracts
---------
- All 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_apply_instrumentation_no_op()

test_instrumentation_middleware.test_apply_instrumentation_no_op ( )
apply_instrumentation() returns the component unchanged when disabled.

Definition at line 68 of file test_instrumentation_middleware.py.

◆ test_apply_list_return()

test_instrumentation_middleware.test_apply_list_return ( )
apply_instrumentation() instruments each element of a list and preserves the type.

Definition at line 87 of file test_instrumentation_middleware.py.

◆ test_apply_single_component()

test_instrumentation_middleware.test_apply_single_component ( )
apply_instrumentation() rewrites the ID of a single component.

Definition at line 134 of file test_instrumentation_middleware.py.

◆ test_apply_tuple_return()

test_instrumentation_middleware.test_apply_tuple_return ( )
apply_instrumentation() instruments each element of a tuple and preserves the type.

Definition at line 112 of file test_instrumentation_middleware.py.

◆ test_no_double_wrapping()

test_instrumentation_middleware.test_no_double_wrapping ( )
apply_instrumentation() does not re-wrap a component whose ID is already a dict.

Definition at line 155 of file test_instrumentation_middleware.py.

Variable Documentation

◆ _REPO_ROOT

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

Definition at line 50 of file test_instrumentation_middleware.py.

◆ dash_html

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

Definition at line 57 of file test_instrumentation_middleware.py.

◆ html

test_instrumentation_middleware.html = dash_html

Definition at line 58 of file test_instrumentation_middleware.py.