From 17cb8299919e056c8bb564f4cd419495c752a5a6 Mon Sep 17 00:00:00 2001 From: briandevans <252620095+briandevans@users.noreply.github.com> Date: Sat, 27 Jun 2026 00:39:49 -0700 Subject: [PATCH] test(moa): cover non-list/bare-dict reference_models normalization --- tests/hermes_cli/test_moa_config.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/hermes_cli/test_moa_config.py b/tests/hermes_cli/test_moa_config.py index 51f80b8067b..26781a7474c 100644 --- a/tests/hermes_cli/test_moa_config.py +++ b/tests/hermes_cli/test_moa_config.py @@ -76,6 +76,24 @@ def test_normalize_moa_config_tolerates_non_numeric_values(): assert preset["aggregator_temperature"] == 0.4 +def test_normalize_moa_config_tolerates_non_list_reference_models(): + """A hand-edited scalar reference_models must degrade to defaults instead of + crashing normalize_moa_config with TypeError (symmetric with the non-numeric + scalar-field tolerance).""" + cfg = normalize_moa_config( + {"presets": {"broken": {"reference_models": 2}}} + ) + assert cfg["presets"]["broken"]["reference_models"] == DEFAULT_MOA_REFERENCE_MODELS + + +def test_normalize_moa_config_wraps_bare_dict_reference_models(): + """A single reference slot written without the list wrapper is rescued.""" + cfg = normalize_moa_config( + {"presets": {"p": {"reference_models": {"provider": "openai", "model": "gpt-4o"}}}} + ) + assert cfg["presets"]["p"]["reference_models"] == [{"provider": "openai", "model": "gpt-4o"}] + + def test_normalize_moa_config_coerces_numeric_strings(): """Valid numeric strings (e.g. from YAML round-trip) must coerce correctly.""" cfg = normalize_moa_config({"max_tokens": "8192", "reference_temperature": "0.9"})