mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-07-15 17:06:06 +00:00
98a633c712
- Implement tests for DingTalk adapter helper functions including form content cleaning, input extraction, and completed input lines. - Create unit tests for Lark adapter helper functions focusing on input extraction and completed input lines. - Add tests for WeComBot template card functionalities, including event extraction and payload building for human input. - Enhance Dify service API runner tests to cover human input forms, including input collection, action handling, and form snapshot extraction.
43 lines
1.3 KiB
Python
43 lines
1.3 KiB
Python
"""Tests for DingTalk API payload helpers."""
|
|
|
|
import json
|
|
|
|
from langbot.libs.dingtalk_api.api import _stringify_card_param_map
|
|
|
|
|
|
def test_dingtalk_card_param_map_stringifies_select_component_arrays():
|
|
params = _stringify_card_param_map(
|
|
{
|
|
'content': 'Pick one',
|
|
'btns': json.dumps([{'text': 'OK'}], ensure_ascii=False),
|
|
'select_options': ['A', 'B'],
|
|
'index_o': [
|
|
{
|
|
'value': 'A',
|
|
'text': {'zh_CN': 'A', 'en_US': 'A'},
|
|
}
|
|
],
|
|
'test_index': [
|
|
{
|
|
'value': 'A',
|
|
'text': {'zh_CN': 'A', 'en_US': 'A'},
|
|
}
|
|
],
|
|
'select_index': -1,
|
|
}
|
|
)
|
|
|
|
assert params['content'] == 'Pick one'
|
|
assert params['btns'] == '[{"text": "OK"}]'
|
|
assert params['select_options'] == '["A", "B"]'
|
|
assert json.loads(params['index_o'])[0]['value'] == 'A'
|
|
assert json.loads(params['test_index'])[0]['value'] == 'A'
|
|
assert params['select_index'] == '-1'
|
|
|
|
|
|
def test_dingtalk_card_param_map_stringifies_unregistered_structures():
|
|
params = _stringify_card_param_map({'other': ['A'], 'empty': None})
|
|
|
|
assert params['other'] == '["A"]'
|
|
assert params['empty'] == ''
|