Enhance client mode handling in ProcessRequest_chat
- Introduced a normalization function for client mode to default to "direct" when input is empty or None. - Updated the clientMode field to use a new type with BeforeValidator for improved validation. - Added a test to ensure empty client mode inputs correctly default to "direct".
This commit is contained in:
@@ -36,6 +36,18 @@ def test_unknown_client_mode_is_rejected():
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("client_mode", ["", " ", None])
|
||||
def test_empty_client_mode_defaults_to_direct(client_mode):
|
||||
request = ProcessRequest_chat(
|
||||
sessionId="session-1",
|
||||
timeStamp="1",
|
||||
text="你好",
|
||||
clientMode=client_mode,
|
||||
)
|
||||
|
||||
assert request.clientMode == "direct"
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("client_mode", "raw_code", "expected"),
|
||||
[
|
||||
|
||||
Reference in New Issue
Block a user