aboutsummaryrefslogtreecommitdiff
path: root/app/tests/test_backends_audiocpp.py
diff options
context:
space:
mode:
Diffstat (limited to 'app/tests/test_backends_audiocpp.py')
-rw-r--r--app/tests/test_backends_audiocpp.py73
1 files changed, 73 insertions, 0 deletions
diff --git a/app/tests/test_backends_audiocpp.py b/app/tests/test_backends_audiocpp.py
index d364c06..ab405aa 100644
--- a/app/tests/test_backends_audiocpp.py
+++ b/app/tests/test_backends_audiocpp.py
@@ -406,6 +406,18 @@ class FindLocalCheckoutTests(unittest.TestCase):
self.assertIsNone(make_server.build.find_local_checkout())
+def _add_options_to_spec(checkout: Path, family: str, *,
+ options=None) -> None:
+ """Rewrite one family spec with an (optional) options block."""
+ path = checkout / "model_specs" / f"{family}.json"
+ spec = json.loads(path.read_text(encoding="utf-8"))
+ if options is not None:
+ spec["options"] = options
+ elif "options" in spec:
+ del spec["options"]
+ path.write_text(json.dumps(spec), encoding="utf-8")
+
+
class LoadModelCatalogTests(unittest.TestCase):
def setUp(self):
self._td = tempfile.TemporaryDirectory()
@@ -468,6 +480,67 @@ class LoadModelCatalogTests(unittest.TestCase):
make_server.catalog.load_model_catalog(empty)
+class RequestOptionsFamiliesTests(unittest.TestCase):
+ """request_options_families: which specs declare request options."""
+
+ def setUp(self):
+ self._td = tempfile.TemporaryDirectory()
+ self.checkout = _make_checkout(Path(self._td.name))
+ _add_options_to_spec(
+ self.checkout, "higgs_audio_tts",
+ options={"request": [{"id": "temperature", "default": 0.8},
+ {"id": "speed"}]})
+
+ def tearDown(self):
+ self._td.cleanup()
+
+ def test_family_with_request_options_listed_with_display_name(self):
+ families = make_server.request_options_families(self.checkout)
+ self.assertEqual(families.get("higgs_audio_tts"),
+ {"display_name": "Higgs Audio v3 TTS 4B"})
+
+ def test_family_without_options_block_absent(self):
+ families = make_server.request_options_families(self.checkout)
+ self.assertNotIn("qwen3_tts", families)
+ self.assertNotIn("voxcpm2", families)
+
+ def test_empty_request_list_does_not_count_as_support(self):
+ _add_options_to_spec(self.checkout, "supertonic",
+ options={"request": []})
+ families = make_server.request_options_families(self.checkout)
+ self.assertNotIn("supertonic", families)
+
+ def test_missing_specs_dir_yields_empty_map(self):
+ self.assertEqual(make_server.request_options_families(
+ Path(self._td.name)), {})
+
+ def test_unparsable_spec_skipped(self):
+ (self.checkout / "model_specs" / "broken.json").write_text(
+ "{not json", encoding="utf-8")
+ families = make_server.request_options_families(self.checkout)
+ self.assertNotIn("broken", families)
+ self.assertIn("higgs_audio_tts", families)
+
+
+class SupportsRequestOptionsTests(unittest.TestCase):
+ """supports_request_options: True / False / unknown tri-state."""
+
+ FAMILIES = {"higgs_audio_tts": {"display_name": "Higgs"}}
+
+ def test_true_only_for_a_listed_family(self):
+ self.assertTrue(make_server.supports_request_options(
+ self.FAMILIES, "higgs_audio_tts"))
+
+ def test_false_for_a_read_but_unlisted_family(self):
+ self.assertFalse(make_server.supports_request_options(
+ self.FAMILIES, "qwen3_tts"))
+
+ def test_none_when_no_local_specs_exist(self):
+ self.assertIsNone(make_server.supports_request_options({}, "any"))
+ # An entry with no family at all is unclassifiable too.
+ self.assertIsNone(make_server.supports_request_options({}, ""))
+
+
class DetectBackendTests(unittest.TestCase):
"""Backend detection from audio.cpp build directory names."""