mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-24 14:42:11 -03:00
feat: add license information handling for Civitai models
Add license resolution utilities and integrate license information into model metadata processing. The changes include: - Add `resolve_license_payload` function to extract license data from Civitai model responses - Integrate license information into model metadata in CivitaiClient and MetadataSyncService - Add license flags support in model scanning and caching - Implement CommercialUseLevel enum for standardized license classification - Update model scanner to handle unknown fields when extracting metadata values This ensures proper license attribution and compliance when working with Civitai models.
This commit is contained in:
35
tests/utils/test_civitai_utils.py
Normal file
35
tests/utils/test_civitai_utils.py
Normal file
@@ -0,0 +1,35 @@
|
||||
from py.utils.civitai_utils import (
|
||||
CommercialUseLevel,
|
||||
build_license_flags,
|
||||
resolve_license_info,
|
||||
resolve_license_payload,
|
||||
)
|
||||
|
||||
|
||||
def test_resolve_license_payload_defaults():
|
||||
payload, flags = resolve_license_info({})
|
||||
|
||||
assert payload["allowNoCredit"] is True
|
||||
assert payload["allowDerivatives"] is True
|
||||
assert payload["allowDifferentLicense"] is True
|
||||
assert payload["allowCommercialUse"] == ["Sell"]
|
||||
assert flags == 57
|
||||
|
||||
|
||||
def test_build_license_flags_custom_values():
|
||||
source = {
|
||||
"allowNoCredit": False,
|
||||
"allowCommercialUse": {"Image", "Sell"},
|
||||
"allowDerivatives": False,
|
||||
"allowDifferentLicense": False,
|
||||
}
|
||||
|
||||
payload = resolve_license_payload(source)
|
||||
assert payload["allowNoCredit"] is False
|
||||
assert set(payload["allowCommercialUse"]) == {"Image", "Sell"}
|
||||
assert payload["allowDerivatives"] is False
|
||||
assert payload["allowDifferentLicense"] is False
|
||||
|
||||
flags = build_license_flags(source)
|
||||
# Highest commercial level is SELL -> level 4 -> shifted by 1 == 8.
|
||||
assert flags == (CommercialUseLevel.SELL << 1)
|
||||
Reference in New Issue
Block a user