diff --git a/tinyml-modelmaker/tests/test_config_validation.py b/tinyml-modelmaker/tests/test_config_validation.py index 26bcd8a..bb8dd2e 100644 --- a/tinyml-modelmaker/tests/test_config_validation.py +++ b/tinyml-modelmaker/tests/test_config_validation.py @@ -10,6 +10,8 @@ import pytest import yaml +from tinyml_modelmaker.ai_modules.audio import training as audio_training +from tinyml_modelmaker.ai_modules.audio import constants as audio_constants from tinyml_modelmaker.ai_modules.timeseries import training, constants @@ -38,8 +40,12 @@ def _find_example_configs(): EXAMPLE_CONFIGS = _find_example_configs() -# Known valid task types (timeseries + vision) -KNOWN_TASK_TYPES = set(constants.TASK_TYPE_TO_CATEGORY.keys()) | {"image_classification"} +# Known valid task types (timeseries + vision + audio) +KNOWN_TASK_TYPES = ( + set(constants.TASK_TYPE_TO_CATEGORY.keys()) + | set(audio_constants.TASK_TYPES) + | {"image_classification"} +) # Required top-level keys in every config REQUIRED_SECTIONS = {"common", "training"} @@ -150,7 +156,8 @@ def test_model_name_exists_in_registry(self, config_path): if task_type == "image_classification": pytest.skip("Vision model registry not tested here") - desc = training.get_model_description(model_name) + registry = audio_training if task_type in audio_constants.TASK_TYPES else training + desc = registry.get_model_description(model_name) assert desc is not None, ( f"Config references model '{model_name}' which is not in the registry" ) diff --git a/tinyml-modelmaker/tests/test_constants.py b/tinyml-modelmaker/tests/test_constants.py index 856e8d6..99e0d6b 100644 --- a/tinyml-modelmaker/tests/test_constants.py +++ b/tinyml-modelmaker/tests/test_constants.py @@ -92,8 +92,9 @@ def test_anomaly_returns_classes(self): == ts_constants.DATA_DIR_CLASSES ) - def test_unknown_category_returns_classes(self): - assert ts_constants.get_default_data_dir_for_task("something_else") == ts_constants.DATA_DIR_CLASSES + def test_unknown_category_raises(self): + with pytest.raises(ValueError, match="Unsupported task_category"): + ts_constants.get_default_data_dir_for_task("something_else") def test_vision_returns_classes(self): # Vision module always returns 'classes' diff --git a/tinyml-modelmaker/tests/test_cross_device.py b/tinyml-modelmaker/tests/test_cross_device.py index 4f4c1d8..73eceea 100644 --- a/tinyml-modelmaker/tests/test_cross_device.py +++ b/tinyml-modelmaker/tests/test_cross_device.py @@ -355,7 +355,7 @@ class TestQuantizationFlags: def test_float_mode_no_normalize(self, task_category): """Quantization=0 (float) should set skip_normalize=False, output_int=False.""" skip, output = constants.get_skip_normalize_and_output_int( - task_category, quantization=0, partial_quantization=False + task_category, quantization=0, auto_quantization=False ) assert skip is False assert output is False @@ -364,7 +364,7 @@ def test_classification_quant_sets_output_int(self): """Classification with quantization should set output_int=True.""" skip, output = constants.get_skip_normalize_and_output_int( constants.TASK_CATEGORY_TS_CLASSIFICATION, - quantization=1, partial_quantization=False, + quantization=1, auto_quantization=False, ) assert skip is True assert output is True @@ -373,7 +373,7 @@ def test_regression_quant_no_output_int(self): """Regression with quantization should set output_int=False.""" skip, output = constants.get_skip_normalize_and_output_int( constants.TASK_CATEGORY_TS_REGRESSION, - quantization=1, partial_quantization=False, + quantization=1, auto_quantization=False, ) assert skip is True assert output is False @@ -382,16 +382,16 @@ def test_forecasting_quant_no_output_int(self): """Forecasting with quantization should set output_int=False.""" skip, output = constants.get_skip_normalize_and_output_int( constants.TASK_CATEGORY_TS_FORECASTING, - quantization=1, partial_quantization=False, + quantization=1, auto_quantization=False, ) assert skip is True assert output is False - def test_partial_quant_regression_override(self): - """Partial quantization for regression should set skip_normalize=False.""" + def test_auto_quant_regression_override(self): + """Auto quantization for regression should set skip_normalize=False.""" skip, output = constants.get_skip_normalize_and_output_int( constants.TASK_CATEGORY_TS_REGRESSION, - quantization=1, partial_quantization=True, + quantization=1, auto_quantization=True, ) assert skip is False assert output is False diff --git a/tinyml-modelmaker/tests/test_dataset_utils.py b/tinyml-modelmaker/tests/test_dataset_utils.py index e098711..895c564 100644 --- a/tinyml-modelmaker/tests/test_dataset_utils.py +++ b/tinyml-modelmaker/tests/test_dataset_utils.py @@ -58,7 +58,7 @@ def test_split_factor_too_large(self, tmp_path): fl = tmp_path / "file_list.txt" fl.write_text("a.csv\nb.csv\n") split_files = (str(tmp_path / "train.txt"), str(tmp_path / "val.txt")) - with pytest.raises(ValueError, match="less than 1"): + with pytest.raises(ValueError, match=r"range \(0\.0, 1\.0\)"): dataset_utils.create_inter_file_split(str(fl), split_files, 1.5) def test_split_factor_list_sum_too_large(self, tmp_path):