STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
test_code_constants Namespace Reference

Functions

str _read (str rel_path)
 test_module_is_a_nonempty_list_within_the_stated_range ()
 test_no_duplicate_name_where_pairs ()
 test_entry_schema (i, entry)
 test_entry_file_exists (i, entry)
 test_entry_symbol_appears_in_file (i, entry)
 test_categories_are_all_represented ()
 test_this_test_actually_catches_a_broken_entry ()

Variables

 REPO_ROOT = Path(__file__).resolve().parents[1]
dict _CATEGORIES
dict _REQUIRED_KEYS = {"name", "value", "where", "meaning", "category", "affects_results"}
dict _FILE_CACHE = {}

Detailed Description

CODE_CONSTANTS is the register behind the Parameters workspace's "In code" section
(``GET /api/config/parameters`` -> ``backend/routers/config.py`` -> ``ConstantsTable`` in
``frontend/src/components/ParametersWorkspace.tsx``). Every entry claims a specific file and a
specific symbol in it; this test is the only thing that checks the claim is still true, since
nothing else re-reads this module against the source it describes.

Function Documentation

◆ _read()

str test_code_constants._read ( str rel_path)
protected

◆ test_categories_are_all_represented()

test_code_constants.test_categories_are_all_represented ( )
Every category the frontend can filter by should have at least one entry, or the filter
silently shows nothing -- a smell that a whole area of code was never surveyed.

Definition at line 126 of file test_code_constants.py.

◆ test_entry_file_exists()

test_code_constants.test_entry_file_exists ( i,
entry )

Definition at line 97 of file test_code_constants.py.

References split().

◆ test_entry_schema()

test_code_constants.test_entry_schema ( i,
entry )
Every entry has exactly the required keys, with the right types and constraints.

Definition at line 64 of file test_code_constants.py.

◆ test_entry_symbol_appears_in_file()

test_code_constants.test_entry_symbol_appears_in_file ( i,
entry )
The claimed symbol must actually appear in the claimed file, as a whole identifier.

``where`` may name a dotted path like ``ClassName.method_name`` or a bracketed dict access
like ``TABLE['key']``; we check the last bare identifier component, since that is the part a
reader would actually search for, and it is robust to the class/function/constant living on
different lines than any wrapping name.

Definition at line 104 of file test_code_constants.py.

References _read(), and split().

◆ test_module_is_a_nonempty_list_within_the_stated_range()

test_code_constants.test_module_is_a_nonempty_list_within_the_stated_range ( )

Definition at line 44 of file test_code_constants.py.

◆ test_no_duplicate_name_where_pairs()

test_code_constants.test_no_duplicate_name_where_pairs ( )

Definition at line 52 of file test_code_constants.py.

◆ test_this_test_actually_catches_a_broken_entry()

test_code_constants.test_this_test_actually_catches_a_broken_entry ( )
A test that cannot fail is not a test (CLAUDE.md). Prove the file/symbol checks above are
live by running them against entries engineered to be wrong, using the exact same logic.

Definition at line 134 of file test_code_constants.py.

References _read(), and split().

Variable Documentation

◆ _CATEGORIES

dict test_code_constants._CATEGORIES
protected
Initial value:
1= {
2 "Propellants",
3 "Injector",
4 "Discharge & Cd",
5 "Combustion efficiency",
6 "Chamber & nozzle",
7 "Thermal protection",
8 "Stability",
9 "Feed & tanks",
10 "Vehicle & flight",
11 "Optimizer",
12}

Definition at line 19 of file test_code_constants.py.

◆ _FILE_CACHE

dict test_code_constants._FILE_CACHE = {}
protected

Definition at line 35 of file test_code_constants.py.

◆ _REQUIRED_KEYS

dict test_code_constants._REQUIRED_KEYS = {"name", "value", "where", "meaning", "category", "affects_results"}
protected

Definition at line 32 of file test_code_constants.py.

◆ REPO_ROOT

test_code_constants.REPO_ROOT = Path(__file__).resolve().parents[1]

Definition at line 17 of file test_code_constants.py.