feat: profiles delete_profile
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -70,3 +70,13 @@ def rename_profile(base, pid, name):
|
||||
entry["name"] = name
|
||||
write_registry(base, reg)
|
||||
return entry
|
||||
|
||||
|
||||
def delete_profile(base, pid):
|
||||
reg = read_registry(base)
|
||||
reg["profiles"] = [p for p in reg["profiles"] if p["id"] != pid]
|
||||
write_registry(base, reg)
|
||||
d = Path(base) / pid
|
||||
if d.exists():
|
||||
shutil.rmtree(d)
|
||||
return reg
|
||||
|
||||
@@ -47,3 +47,10 @@ def test_rename_to_existing_name_raises(tmp_path):
|
||||
pr.create_profile(str(tmp_path), "b", "id2")
|
||||
with pytest.raises(ValueError):
|
||||
pr.rename_profile(str(tmp_path), "id2", "a")
|
||||
|
||||
def test_delete_profile_removes_dir_and_entry(tmp_path):
|
||||
pr.create_profile(str(tmp_path), "a", "id1")
|
||||
(tmp_path / "id1" / "img_0001.png").write_bytes(b"x")
|
||||
pr.delete_profile(str(tmp_path), "id1")
|
||||
assert not (tmp_path / "id1").exists()
|
||||
assert pr.find_by_id(pr.read_registry(str(tmp_path)), "id1") is None
|
||||
|
||||
Reference in New Issue
Block a user