mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-03-10 15:50:02 +00:00
global refactoring; add support for Assets without the computed hash
This commit is contained in:
@@ -118,6 +118,16 @@ async def test_head_asset_by_hash(http: aiohttp.ClientSession, api_base: str, se
|
||||
assert rh2.status == 404
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_head_asset_bad_hash_returns_400_and_no_body(http: aiohttp.ClientSession, api_base: str):
|
||||
# Invalid format; handler returns a JSON error, but HEAD responses must not carry a payload.
|
||||
# aiohttp exposes an empty body for HEAD, so validate status and that there is no payload.
|
||||
async with http.head(f"{api_base}/api/assets/hash/not_a_hash") as rh:
|
||||
assert rh.status == 400
|
||||
body = await rh.read()
|
||||
assert body == b""
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_delete_nonexistent_returns_404(http: aiohttp.ClientSession, api_base: str):
|
||||
bogus = str(uuid.uuid4())
|
||||
@@ -166,12 +176,3 @@ async def test_update_requires_at_least_one_field(http: aiohttp.ClientSession, a
|
||||
body = await r.json()
|
||||
assert r.status == 400
|
||||
assert body["error"]["code"] == "INVALID_BODY"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_head_asset_bad_hash(http: aiohttp.ClientSession, api_base: str):
|
||||
# Invalid format
|
||||
async with http.head(f"{api_base}/api/assets/hash/not_a_hash") as rh3:
|
||||
jb = await rh3.json()
|
||||
assert rh3.status == 400
|
||||
assert jb is None # HEAD request should not include "body" in response
|
||||
|
||||
@@ -66,23 +66,32 @@ async def test_add_and_remove_tags(http: aiohttp.ClientSession, api_base: str, s
|
||||
async with http.post(f"{api_base}/api/assets/{aid}/tags", json=payload_add) as r1:
|
||||
b1 = await r1.json()
|
||||
assert r1.status == 200, b1
|
||||
# normalized and deduplicated
|
||||
assert "newtag" in b1["added"] or "beta" in b1["added"] or "unit-tests" not in b1["added"]
|
||||
# normalized, deduplicated; 'unit-tests' was already present from the seed
|
||||
assert set(b1["added"]) == {"newtag", "beta"}
|
||||
assert set(b1["already_present"]) == {"unit-tests"}
|
||||
assert "newtag" in b1["total_tags"] and "beta" in b1["total_tags"]
|
||||
|
||||
async with http.get(f"{api_base}/api/assets/{aid}") as rg:
|
||||
g = await rg.json()
|
||||
assert rg.status == 200
|
||||
tags_now = set(g["tags"])
|
||||
assert "newtag" in tags_now
|
||||
assert "beta" in tags_now
|
||||
assert {"newtag", "beta"}.issubset(tags_now)
|
||||
|
||||
# Remove a tag and a non-existent tag
|
||||
payload_del = {"tags": ["newtag", "does-not-exist"]}
|
||||
async with http.delete(f"{api_base}/api/assets/{aid}/tags", json=payload_del) as r2:
|
||||
b2 = await r2.json()
|
||||
assert r2.status == 200
|
||||
assert "newtag" in b2["removed"]
|
||||
assert "does-not-exist" in b2["not_present"]
|
||||
assert set(b2["removed"]) == {"newtag"}
|
||||
assert set(b2["not_present"]) == {"does-not-exist"}
|
||||
|
||||
# Verify remaining tags after deletion
|
||||
async with http.get(f"{api_base}/api/assets/{aid}") as rg2:
|
||||
g2 = await rg2.json()
|
||||
assert rg2.status == 200
|
||||
tags_later = set(g2["tags"])
|
||||
assert "newtag" not in tags_later
|
||||
assert "beta" in tags_later # still present
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
||||
@@ -206,7 +206,7 @@ async def test_upload_models_unknown_category(http: aiohttp.ClientSession, api_b
|
||||
body = await r.json()
|
||||
assert r.status == 400
|
||||
assert body["error"]["code"] == "INVALID_BODY"
|
||||
assert "unknown models category" in body["error"]["message"] or "unknown model category" in body["error"]["message"]
|
||||
assert body["error"]["message"].startswith("unknown models category")
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
||||
Reference in New Issue
Block a user