aboutsummaryrefslogtreecommitdiff
path: root/app/tests/test_backends_audiocpp.py
diff options
context:
space:
mode:
authorhistoria <historiavg@proton.me>2026-08-28 14:57:48 -0400
committerhistoria <historiavg@proton.me>2026-08-28 14:57:48 -0400
commitdb38085d07ce75f8961eecdc1919e98748254c53 (patch)
treebeaea2ba84de05bfc2fa90e9b92a24568d3b4cb9 /app/tests/test_backends_audiocpp.py
parentafb2c2d5b297c5aa28bcced0e3f90e207d799c2a (diff)
downloadtts-audiobook-generator-db38085d07ce75f8961eecdc1919e98748254c53.tar.gz
refactor: overhaul config.py, remove cli default options
Diffstat (limited to 'app/tests/test_backends_audiocpp.py')
-rw-r--r--app/tests/test_backends_audiocpp.py98
1 files changed, 10 insertions, 88 deletions
diff --git a/app/tests/test_backends_audiocpp.py b/app/tests/test_backends_audiocpp.py
index 95f8bec..82d6b88 100644
--- a/app/tests/test_backends_audiocpp.py
+++ b/app/tests/test_backends_audiocpp.py
@@ -27,14 +27,6 @@ FAKE_CONFIG = (
"CHUNK_SIZE = 250\n"
)
-FAKE_CONFIG_WITH_MODEL_IDS = (
- 'AUDIOCPP_API_URL = "http://127.0.0.1:9999" # audio.cpp audiocpp_server\n'
- "\n"
- 'AUDIOCPP_MODEL_ID = "qwen" # server entry for speaker mode\n'
- 'AUDIOCPP_CLONE_MODEL_ID = "qwen-clone"\n'
-)
-
-
def _write_spec(checkout: Path, family: str, *, display_name=None,
tasks=("tts", "clone"), languages=("en",), packages=None,
category="tts"):
@@ -278,59 +270,6 @@ class UpdateConfigPortTests(unittest.TestCase):
8080, config_path=Path(self._tmp.name) / "nope.py"))
-class UpdateConfigModelIdsTests(unittest.TestCase):
- def setUp(self):
- self._tmp = tempfile.TemporaryDirectory()
- self.config_path = Path(self._tmp.name) / "config.py"
- self.config_path.write_text(FAKE_CONFIG_WITH_MODEL_IDS,
- encoding="utf-8")
- # The shared helper also mirrors values onto converter.config.
- self._saved_ids = (config.AUDIOCPP_MODEL_ID,
- config.AUDIOCPP_CLONE_MODEL_ID)
-
- def tearDown(self):
- (config.AUDIOCPP_MODEL_ID,
- config.AUDIOCPP_CLONE_MODEL_ID) = self._saved_ids
- self._tmp.cleanup()
-
- def test_rewrites_both_ids_preserving_lines(self):
- changed = make_server.configsync.update_config_model_ids(
- "higgs", "higgs", config_path=self.config_path)
- self.assertTrue(changed)
- text = self.config_path.read_text(encoding="utf-8")
- self.assertIn('AUDIOCPP_MODEL_ID = "higgs" # server entry for speaker mode',
- text)
- self.assertIn('AUDIOCPP_CLONE_MODEL_ID = "higgs"', text)
- self.assertIn('AUDIOCPP_API_URL = "http://127.0.0.1:9999"', text)
-
- def test_clone_id_optional(self):
- changed = make_server.configsync.update_config_model_ids(
- "voxcpm2", config_path=self.config_path)
- self.assertTrue(changed)
- text = self.config_path.read_text(encoding="utf-8")
- self.assertIn('AUDIOCPP_MODEL_ID = "voxcpm2"', text)
- self.assertIn('AUDIOCPP_CLONE_MODEL_ID = "qwen-clone"', text)
-
- def test_ids_unchanged_is_a_success_noop(self):
- # Both ids already hold their values: success, nothing rewritten.
- changed = make_server.configsync.update_config_model_ids(
- "qwen", "qwen-clone", config_path=self.config_path)
- self.assertTrue(changed)
- self.assertEqual(self.config_path.read_text(encoding="utf-8"),
- FAKE_CONFIG_WITH_MODEL_IDS)
-
- def test_returns_false_when_lines_missing(self):
- path = Path(self._tmp.name) / "other.py"
- path.write_text('CHUNK_SIZE = 250\n', encoding="utf-8")
- self.assertFalse(make_server.configsync.update_config_model_ids(
- "higgs", "higgs", config_path=path))
-
- def test_returns_false_when_file_missing(self):
- self.assertFalse(make_server.configsync.update_config_model_ids(
- "higgs", "higgs",
- config_path=Path(self._tmp.name) / "nope.py"))
-
-
class ResolveWavDirArgTests(unittest.TestCase):
def setUp(self):
self._tmp = tempfile.TemporaryDirectory()
@@ -1934,7 +1873,7 @@ class NonInteractiveMainTests(unittest.TestCase):
def test_default_run_hosts_recommended_entry(self):
exit_code = self._run(
- self._args("--families", "higgs_audio_tts", "--no-sync-model-ids"))
+ self._args("--families", "higgs_audio_tts"))
self.assertEqual(exit_code, 0)
data = json.loads(self.output.read_text(encoding="utf-8"))
self.assertEqual(data["host"], "127.0.0.1")
@@ -1952,8 +1891,7 @@ class NonInteractiveMainTests(unittest.TestCase):
with patch.object(config, "AUDIOCPP_API_URL",
"http://127.0.0.1:9999"):
exit_code = self._run(
- self._args("--families", "higgs_audio_tts",
- "--no-sync-model-ids"))
+ self._args("--families", "higgs_audio_tts"))
self.assertEqual(exit_code, 0)
self.assertIn('"http://127.0.0.1:9999"',
self.fake_config.read_text(encoding="utf-8"))
@@ -1968,21 +1906,10 @@ class NonInteractiveMainTests(unittest.TestCase):
with self.assertRaises(SystemExit):
parser.parse_args([flag, "x"])
- def test_model_id_sync_accepted_updates_config(self):
- self.fake_config.write_text(FAKE_CONFIG_WITH_MODEL_IDS,
- encoding="utf-8")
- exit_code = self._run(self._args("--families", "higgs_audio_tts"))
- self.assertEqual(exit_code, 0)
- text = self.fake_config.read_text(encoding="utf-8")
- self.assertIn('AUDIOCPP_MODEL_ID = "Higgs-Audio-v3-TTS-4B-GGUF"', text)
- self.assertIn('AUDIOCPP_CLONE_MODEL_ID = "Higgs-Audio-v3-TTS-4B-GGUF"',
- text)
-
def test_multi_family_lazy_with_voice_dir(self):
(self.folder / "narrator.wav").write_bytes(b"x")
exit_code = self._run(
- self._args("--families", "qwen3_tts,higgs_audio_tts",
- "--no-sync-model-ids"),
+ self._args("--families", "qwen3_tts,higgs_audio_tts"),
transcribe=lambda path, model_name="base": "a transcript")
self.assertEqual(exit_code, 0)
data = json.loads(self.output.read_text(encoding="utf-8"))
@@ -1998,8 +1925,7 @@ class NonInteractiveMainTests(unittest.TestCase):
def test_force_overwrites_existing_output(self):
self.output.write_text('{"old": true}', encoding="utf-8")
exit_code = self._run(
- self._args("--families", "higgs_audio_tts", "--force",
- "--no-sync-model-ids"))
+ self._args("--families", "higgs_audio_tts", "--force"))
self.assertEqual(exit_code, 0)
data = json.loads(self.output.read_text(encoding="utf-8"))
self.assertEqual(len(data["models"]), 1)
@@ -2007,15 +1933,14 @@ class NonInteractiveMainTests(unittest.TestCase):
def test_existing_output_declined_keeps_file(self):
self.output.write_text('{"old": true}', encoding="utf-8")
exit_code = self._run(
- self._args("--families", "higgs_audio_tts", "--no-sync-model-ids"))
+ self._args("--families", "higgs_audio_tts"))
self.assertEqual(exit_code, 1)
self.assertEqual(json.loads(self.output.read_text(encoding="utf-8")),
{"old": True})
def test_all_packages_hosts_design_as_vdes(self):
exit_code = self._run(
- self._args("--families", "qwen3_tts", "--all-packages",
- "--no-sync-model-ids"))
+ self._args("--families", "qwen3_tts", "--all-packages"))
self.assertEqual(exit_code, 0)
data = json.loads(self.output.read_text(encoding="utf-8"))
by_id = {m["id"]: m for m in data["models"]}
@@ -2029,14 +1954,13 @@ class NonInteractiveMainTests(unittest.TestCase):
def test_unknown_family_rejected(self):
with self.assertRaises(SystemExit) as ctx:
- self._run(self._args("--families", "not_a_family",
- "--no-sync-model-ids"))
+ self._run(self._args("--families", "not_a_family"))
self.assertEqual(ctx.exception.code, 2)
def test_missing_checkout_rejected(self):
with self.assertRaises(SystemExit) as ctx:
self._run(["--families", "higgs_audio_tts", "--output",
- str(self.output), "--no-sync-model-ids"],
+ str(self.output)],
no_checkout=True)
self.assertEqual(ctx.exception.code, 2)
@@ -2044,12 +1968,12 @@ class NonInteractiveMainTests(unittest.TestCase):
missing = self.root / "nope"
with self.assertRaises(SystemExit) as ctx:
self._run(["--wavs", str(missing), "--output", str(self.output),
- "--families", "higgs_audio_tts", "--no-sync-model-ids"])
+ "--families", "higgs_audio_tts"])
self.assertEqual(ctx.exception.code, 2)
def test_families_required_in_noninteractive_run(self):
with self.assertRaises(SystemExit) as ctx:
- self._run(self._args("--no-sync-model-ids"))
+ self._run(self._args())
self.assertEqual(ctx.exception.code, 2)
@@ -2666,7 +2590,6 @@ class WizardNavigationTests(unittest.TestCase):
self.assertEqual(settings["backend"], "cuda") # default choice
self.assertTrue(settings["build"]) # not built yet → offered (default Yes)
self.assertFalse(settings["download"]) # no manager script here
- self.assertTrue(settings["sync_model_ids"])
def test_tree_screen_starts_on_confirm(self):
# The model-tree screen opens with focus on Confirm so Enter
@@ -2895,7 +2818,6 @@ class ExecuteLanesTests(unittest.TestCase):
"wav_dir": None,
"plan": None,
"sync_port": None,
- "sync_model_ids": None,
"delete_unused": False,
"unused_entries": [],
"model_entries": [],