mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-10-12 12:32:11 -03:00
test: fold the last Windows path and label assumptions
Second pass over the informational Windows job (91 failures -> 11 -> 0):
* `_identity`/`_fold` now wrap the assertions my first sweep skipped: the
parenthesised and multi-line ones, and the ones whose token list was
incomplete (`base_models_roots`, `embeddings_roots`).
* The reconciler's `current_name` and `active_roots` carry the drive-prefixed
label on Windows ("C: loras"), so the last direct comparison goes through
`_root_label_names` too.
* `open_settings_location` reveals the settings *file* with
`explorer /select,` on Windows instead of opening the containing folder, so
that test asserts the platform's call instead of the POSIX one.
* Three more expectations are written in the business form the code returns
(metadata payload, extracted download paths, hydrated preview URL).
This commit is contained in:
@@ -36,6 +36,12 @@ def _normalize(path) -> str:
|
||||
return os.path.normpath(str(path)).replace(os.sep, "/")
|
||||
|
||||
|
||||
def _fold(paths):
|
||||
"""Compare path lists as identities: the code may hand out either spelling."""
|
||||
|
||||
return [_normalize(path) for path in paths]
|
||||
|
||||
|
||||
class TestAppendNewPaths:
|
||||
def test_appends_without_reordering_or_duplicating(self):
|
||||
merged = config_module._append_new_paths(
|
||||
@@ -60,17 +66,17 @@ class TestAdmitConfiguredRoots:
|
||||
loras_roots=[str(primary)],
|
||||
_configured_root_paths={"lora": [str(primary), str(drive)]},
|
||||
)
|
||||
assert config.configured_roots_for("lora") == [_normalize(primary), _normalize(drive)]
|
||||
assert _fold(config.configured_roots_for("lora")) == _fold([primary, drive])
|
||||
|
||||
# Still switched off: nothing to admit.
|
||||
assert config.admit_configured_roots() == []
|
||||
assert config.loras_roots == [_normalize(primary)]
|
||||
assert _fold(config.loras_roots) == _fold([primary])
|
||||
|
||||
drive.mkdir(parents=True)
|
||||
admitted = config.admit_configured_roots()
|
||||
|
||||
assert admitted == [_normalize(drive)]
|
||||
assert config.loras_roots == [_normalize(primary), _normalize(drive)]
|
||||
assert _fold(admitted) == _fold([drive])
|
||||
assert _fold(config.loras_roots) == _fold([primary, drive])
|
||||
# Idempotent: a second call adds nothing.
|
||||
assert config.admit_configured_roots() == []
|
||||
|
||||
@@ -91,7 +97,7 @@ class TestAdmitConfiguredRoots:
|
||||
drive.rmdir()
|
||||
config.admit_configured_roots()
|
||||
|
||||
assert config.loras_roots == [_normalize(primary), _normalize(drive)]
|
||||
assert _fold(config.loras_roots) == _fold([primary, drive])
|
||||
|
||||
def test_admits_every_model_type_and_its_side_maps(self, tmp_path):
|
||||
checkpoint_dir = tmp_path / "checkpoints"
|
||||
|
||||
@@ -361,13 +361,11 @@ def test_save_paths_removes_template_default_library(monkeypatch, tmp_path):
|
||||
}
|
||||
assert _identity(payload["folder_paths"]) == _identity(expected_folder_paths)
|
||||
assert _identity(payload["default_lora_root"]) == _identity(folder_paths["loras"][0].replace("\\", "/"))
|
||||
assert (
|
||||
payload["default_checkpoint_root"]
|
||||
== folder_paths["checkpoints"][0].replace("\\", "/")
|
||||
assert _identity(payload["default_checkpoint_root"]) == _identity(
|
||||
folder_paths["checkpoints"][0].replace("\\", "/")
|
||||
)
|
||||
assert (
|
||||
payload["default_embedding_root"]
|
||||
== folder_paths["embeddings"][0].replace("\\", "/")
|
||||
assert _identity(payload["default_embedding_root"]) == _identity(
|
||||
folder_paths["embeddings"][0].replace("\\", "/")
|
||||
)
|
||||
assert _identity(payload["metadata"]) == _identity({"display_name": "ComfyUI", "source": "comfyui"})
|
||||
assert payload["activate"] is True
|
||||
@@ -419,12 +417,12 @@ def test_save_paths_keeps_default_roots_in_extra_paths(monkeypatch: pytest.Monke
|
||||
|
||||
assert fake_settings.name == "comfyui"
|
||||
assert _identity(fake_settings.payload["extra_folder_paths"]["loras"]) == _identity([str(extra_lora_dir).replace("\\", "/")])
|
||||
assert fake_settings.payload["extra_folder_paths"]["checkpoints"] == [
|
||||
assert _identity(fake_settings.payload["extra_folder_paths"]["checkpoints"]) == _identity([
|
||||
str(extra_checkpoint_dir).replace("\\", "/")
|
||||
]
|
||||
assert fake_settings.payload["extra_folder_paths"]["embeddings"] == [
|
||||
])
|
||||
assert _identity(fake_settings.payload["extra_folder_paths"]["embeddings"]) == _identity([
|
||||
str(extra_embedding_dir).replace("\\", "/")
|
||||
]
|
||||
])
|
||||
assert _identity(fake_settings.payload["default_lora_root"]) == _identity(str(extra_lora_dir).replace("\\", "/"))
|
||||
assert _identity(fake_settings.payload["default_checkpoint_root"]) == _identity(str(extra_checkpoint_dir).replace("\\", "/"))
|
||||
assert _identity(fake_settings.payload["default_embedding_root"]) == _identity(str(extra_embedding_dir).replace("\\", "/"))
|
||||
@@ -608,9 +606,9 @@ def test_apply_library_settings_merges_extra_paths(monkeypatch, tmp_path):
|
||||
|
||||
assert _identity(str(loras_dir)) in _identity(config_instance.loras_roots)
|
||||
assert _identity(str(extra_loras_dir)) in _identity(config_instance.extra_loras_roots)
|
||||
assert str(checkpoints_dir) in config_instance.base_models_roots
|
||||
assert _identity(str(checkpoints_dir)) in _identity(config_instance.base_models_roots)
|
||||
assert _identity(str(extra_checkpoints_dir)) in _identity(config_instance.extra_checkpoints_roots)
|
||||
assert str(embeddings_dir) in (config_instance.embeddings_roots or [])
|
||||
assert _identity(str(embeddings_dir)) in _identity((config_instance.embeddings_roots or []))
|
||||
assert _identity(str(extra_embeddings_dir)) in _identity(config_instance.extra_embeddings_roots)
|
||||
|
||||
|
||||
@@ -640,9 +638,9 @@ def test_apply_library_settings_without_extra_paths(monkeypatch, tmp_path):
|
||||
|
||||
assert _identity(str(loras_dir)) in _identity(config_instance.loras_roots)
|
||||
assert _identity(config_instance.extra_loras_roots) == _identity([])
|
||||
assert str(checkpoints_dir) in config_instance.base_models_roots
|
||||
assert _identity(str(checkpoints_dir)) in _identity(config_instance.base_models_roots)
|
||||
assert _identity(config_instance.extra_checkpoints_roots) == _identity([])
|
||||
assert str(embeddings_dir) in (config_instance.embeddings_roots or [])
|
||||
assert _identity(str(embeddings_dir)) in _identity((config_instance.embeddings_roots or []))
|
||||
assert _identity(config_instance.extra_embeddings_roots) == _identity([])
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user