From 31e9cf1f06a9bf283db45c50179f1bab24106de9 Mon Sep 17 00:00:00 2001 From: psychedelicious <4822129+psychedelicious@users.noreply.github.com> Date: Fri, 29 Mar 2024 22:09:55 +1100 Subject: [PATCH] tests: update model install tests for change to paths --- .../model_install/test_model_install.py | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/tests/app/services/model_install/test_model_install.py b/tests/app/services/model_install/test_model_install.py index cfc8e6e83c..ba3088f413 100644 --- a/tests/app/services/model_install/test_model_install.py +++ b/tests/app/services/model_install/test_model_install.py @@ -43,8 +43,7 @@ def test_registration_meta(mm2_installer: ModelInstallServiceBase, embedding_fil assert model_record is not None assert model_record.name == "test_embedding" assert model_record.type == ModelType.TextualInversion - assert model_record.path.endswith(embedding_file.as_posix()) - assert Path(model_record.path).is_absolute() + assert Path(model_record.path) == embedding_file assert Path(model_record.path).exists() assert model_record.base == BaseModelType("sd-1") assert model_record.description is not None @@ -77,8 +76,7 @@ def test_install( key = mm2_installer.install_path(embedding_file) model_record = store.get_model(key) assert model_record.path.endswith("sd-1/embedding/test_embedding.safetensors") - assert Path(model_record.path).is_absolute() - assert Path(model_record.path).exists() + assert (mm2_app_config.models_path / model_record.path).exists() assert model_record.source == embedding_file.as_posix() @@ -147,10 +145,7 @@ def test_background_install( model_record = mm2_installer.record_store.get_model(key) assert model_record is not None assert model_record.path.endswith(destination) - assert Path(model_record.path).is_absolute() - assert Path(model_record.path).exists() - assert model_record.key != "" - assert Path(model_record.path).exists() + assert (mm2_app_config.models_path / model_record.path).exists() # see if metadata was properly passed through assert model_record.description == description @@ -172,7 +167,7 @@ def test_not_inplace_install( assert job is not None assert job.config_out is not None assert Path(job.config_out.path) != embedding_file - assert Path(job.config_out.path).exists() + assert (mm2_app_config.models_path / job.config_out.path).exists() def test_inplace_install( @@ -184,16 +179,21 @@ def test_inplace_install( assert job is not None assert job.config_out is not None assert Path(job.config_out.path) == embedding_file + assert Path(job.config_out.path).exists() -def test_delete_install(mm2_installer: ModelInstallServiceBase, embedding_file: Path) -> None: +def test_delete_install( + mm2_installer: ModelInstallServiceBase, embedding_file: Path, mm2_app_config: InvokeAIAppConfig +) -> None: store = mm2_installer.record_store key = mm2_installer.install_path(embedding_file) model_record = store.get_model(key) - assert Path(model_record.path).exists() + assert (mm2_app_config.models_path / model_record.path).exists() assert embedding_file.exists() # original should still be there after installation mm2_installer.delete(key) - assert not Path(model_record.path).exists() # after deletion, installed copy should not exist + assert not ( + mm2_app_config.models_path / model_record.path + ).exists() # after deletion, installed copy should not exist assert embedding_file.exists() # but original should still be there with pytest.raises(UnknownModelException): store.get_model(key) @@ -232,7 +232,7 @@ def test_simple_download(mm2_installer: ModelInstallServiceBase, mm2_app_config: key = job.config_out.key model_record = store.get_model(key) - assert Path(model_record.path).exists() + assert (mm2_app_config.models_path / model_record.path).exists() assert len(bus.events) == 4 event_names = [x.event_name for x in bus.events] @@ -261,7 +261,7 @@ def test_huggingface_download(mm2_installer: ModelInstallServiceBase, mm2_app_co key = job.config_out.key model_record = store.get_model(key) - assert Path(model_record.path).exists() + assert (mm2_app_config.models_path / model_record.path).exists() assert model_record.type == ModelType.Main assert model_record.format == ModelFormat.Diffusers