diff --git a/test/unit/setting/test_setting.py b/test/unit/setting/test_setting.py index a249c923b..d5781fca3 100644 --- a/test/unit/setting/test_setting.py +++ b/test/unit/setting/test_setting.py @@ -1,22 +1,18 @@ from pathlib import Path from voicevox_engine.setting.model import CorsPolicyMode -from voicevox_engine.setting.setting_manager import ( - Setting, - SettingHandler, - _setting_adapter, -) +from voicevox_engine.setting.setting_manager import Setting, SettingHandler def test_setting_handler_load_not_exist_file() -> None: """`SettingHandler` に存在しない設定ファイルのパスを渡すとデフォルト値になる。""" # Inputs - setting_loader = SettingHandler(Path("not_exist.yaml")) - settings = setting_loader.load() + setting_path = Path("not_exist.yaml") + setting_loader = SettingHandler(setting_path) # Expects - true_setting = {"allow_origin": None, "cors_policy_mode": CorsPolicyMode.localapps} + true_setting = Setting(cors_policy_mode=CorsPolicyMode.localapps, allow_origin=None) # Outputs - setting = _setting_adapter.dump_python(settings) + setting = setting_loader.load() # Test assert true_setting == setting @@ -26,11 +22,10 @@ def test_setting_handler_load_exist_file_1() -> None: # Inputs setting_path = Path("test/unit/setting/setting-test-load-1.yaml") setting_loader = SettingHandler(setting_path) - settings = setting_loader.load() # Expects - true_setting = {"allow_origin": None, "cors_policy_mode": CorsPolicyMode.localapps} + true_setting = Setting(cors_policy_mode=CorsPolicyMode.localapps, allow_origin=None) # Outputs - setting = _setting_adapter.dump_python(settings) + setting = setting_loader.load() # Test assert true_setting == setting @@ -40,11 +35,10 @@ def test_setting_handler_load_exist_file_2() -> None: # Inputs setting_path = Path("test/unit/setting/setting-test-load-2.yaml") setting_loader = SettingHandler(setting_path) - settings = setting_loader.load() # Expects - true_setting = {"allow_origin": None, "cors_policy_mode": "all"} + true_setting = Setting(cors_policy_mode=CorsPolicyMode.all, allow_origin=None) # Outputs - setting = _setting_adapter.dump_python(settings) + setting = setting_loader.load() # Test assert true_setting == setting @@ -54,14 +48,12 @@ def test_setting_handler_load_exist_file_3() -> None: # Inputs setting_path = Path("test/unit/setting/setting-test-load-3.yaml") setting_loader = SettingHandler(setting_path) - settings = setting_loader.load() # Expects - true_setting = { - "allow_origin": "192.168.254.255 192.168.255.255", - "cors_policy_mode": CorsPolicyMode.localapps, - } + true_policy = CorsPolicyMode.localapps + true_origin = "192.168.254.255 192.168.255.255" + true_setting = Setting(cors_policy_mode=true_policy, allow_origin=true_origin) # Outputs - setting = _setting_adapter.dump_python(settings) + setting = setting_loader.load() # Test assert true_setting == setting @@ -73,10 +65,9 @@ def test_setting_handler_save(tmp_path: Path) -> None: setting_loader = SettingHandler(setting_path) new_setting = Setting(cors_policy_mode=CorsPolicyMode.localapps) # Expects - true_setting = {"allow_origin": None, "cors_policy_mode": CorsPolicyMode.localapps} + true_setting = Setting(cors_policy_mode=CorsPolicyMode.localapps, allow_origin=None) # Outputs setting_loader.save(new_setting) - # NOTE: `.load()` の正常動作を前提とする - setting = _setting_adapter.dump_python(setting_loader.load()) + setting = setting_loader.load() # NOTE: `.load()` の正常動作を前提とする # Test assert true_setting == setting