mirror of
https://github.com/langgenius/dify.git
synced 2026-04-29 04:26:30 +08:00
fix(api): make CreatorUserRole accept both end-user and end_user (#33638)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
116cc22019
commit
387e5a345f
@ -11,6 +11,13 @@ class CreatorUserRole(StrEnum):
|
|||||||
ACCOUNT = "account"
|
ACCOUNT = "account"
|
||||||
END_USER = "end_user"
|
END_USER = "end_user"
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _missing_(cls, value):
|
||||||
|
if value == "end-user":
|
||||||
|
return cls.END_USER
|
||||||
|
else:
|
||||||
|
return super()._missing_(value)
|
||||||
|
|
||||||
|
|
||||||
class WorkflowRunTriggeredFrom(StrEnum):
|
class WorkflowRunTriggeredFrom(StrEnum):
|
||||||
DEBUGGING = "debugging"
|
DEBUGGING = "debugging"
|
||||||
|
|||||||
19
api/tests/unit_tests/models/test_enums_creator_user_role.py
Normal file
19
api/tests/unit_tests/models/test_enums_creator_user_role.py
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import pytest
|
||||||
|
|
||||||
|
from models.enums import CreatorUserRole
|
||||||
|
|
||||||
|
|
||||||
|
def test_creator_user_role_missing_maps_hyphen_to_enum():
|
||||||
|
# given an alias with hyphen
|
||||||
|
value = "end-user"
|
||||||
|
|
||||||
|
# when converting to enum (invokes StrEnum._missing_ override)
|
||||||
|
role = CreatorUserRole(value)
|
||||||
|
|
||||||
|
# then it should map to END_USER
|
||||||
|
assert role is CreatorUserRole.END_USER
|
||||||
|
|
||||||
|
|
||||||
|
def test_creator_user_role_missing_raises_for_unknown():
|
||||||
|
with pytest.raises(ValueError):
|
||||||
|
CreatorUserRole("unknown")
|
||||||
Loading…
Reference in New Issue
Block a user