mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-23 14:12:11 -03:00
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.
36 lines
1.1 KiB
Python
36 lines
1.1 KiB
Python
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)
|