Files
Comfy-Org-ComfyUI-Manager/tests/test_openapi_setting_values.py
Dr.Lt.Data a48433cc9a v4: Fix the legacy batch update, the update policy, console messages and settings (#3544)
Six fixes. The CHANGELOG has an entry for each.

- Queue the legacy ComfyUI update and answer failed version requests
- Check out a branch head by its name with GitPython
- Follow the update policy when an update request names no version line
- Print the messages of manager_core as they are
- Refuse a db_mode or update_policy request the servers cannot use
- Keep a setting chosen while the legacy menu is loading it

The E2E cases wait for the Registry list, which a fresh environment has not
cached, and the Playwright cases no longer depend on the timing of the UI.
2026-11-17 12:40:09 +09:00

24 lines
1.1 KiB
Python

"""`openapi.yaml` lists, for `db_mode` and the update policy, the values the routes accept."""
import ast
import pytest
import yaml
from legacy_html_testutil import PACKAGE
SPEC = yaml.safe_load((PACKAGE.parent / "openapi.yaml").read_text(encoding="utf-8"))
ACCEPTED = {node.targets[0].id: ast.literal_eval(node.value)
for node in ast.parse((PACKAGE / "glob/utils/environment_utils.py").read_text(encoding="utf-8")).body
if isinstance(node, ast.Assign) and getattr(node.targets[0], "id", "").startswith("ALLOWED_")}
@pytest.mark.parametrize("route, accepted", [
("/v2/manager/db_mode", "ALLOWED_DB_MODES"),
("/v2/manager/policy/update", "ALLOWED_UPDATE_POLICIES"),
])
def test_values_of_a_setting_route_are_the_ones_the_route_accepts(route, accepted):
answered = SPEC["paths"][route]["get"]["responses"]["200"]["content"]["text/plain"]["schema"]["enum"]
asked = SPEC["paths"][route]["post"]["requestBody"]["content"]["application/json"]["schema"]["properties"]["value"]["enum"]
assert sorted(answered) == sorted(asked) == sorted(ACCEPTED[accepted])