mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-07-17 01:46:07 +00:00
test: cover telegram upload file capability
This commit is contained in:
committed by
huanghuoguoguo
parent
59084e092a
commit
112d91af76
@@ -102,6 +102,18 @@ async def run_api(results: list[dict[str, Any]], name: str, func):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
async def run_expected_error(results: list[dict[str, Any]], name: str, func, error_type_name: str):
|
||||||
|
try:
|
||||||
|
await func()
|
||||||
|
except Exception as exc:
|
||||||
|
if type(exc).__name__ == error_type_name:
|
||||||
|
record_api(results, name, True, {'expected_error': error_type_name})
|
||||||
|
return
|
||||||
|
record_api(results, name, False, error=exc)
|
||||||
|
return
|
||||||
|
record_api(results, name, False, error=RuntimeError(f'expected {error_type_name}'))
|
||||||
|
|
||||||
|
|
||||||
async def run_probe(
|
async def run_probe(
|
||||||
token: str,
|
token: str,
|
||||||
log_path: Path,
|
log_path: Path,
|
||||||
@@ -266,6 +278,12 @@ async def run_probe(
|
|||||||
'get_user_info',
|
'get_user_info',
|
||||||
lambda: adapter.get_user_info(actor_user_id),
|
lambda: adapter.get_user_info(actor_user_id),
|
||||||
)
|
)
|
||||||
|
await run_expected_error(
|
||||||
|
api_results,
|
||||||
|
'upload_file:not_supported',
|
||||||
|
lambda: adapter.upload_file(b'eba-upload-live', 'eba-upload-live.txt'),
|
||||||
|
'NotSupportedError',
|
||||||
|
)
|
||||||
await run_api(
|
await run_api(
|
||||||
api_results,
|
api_results,
|
||||||
'call_platform_api:send_chat_action',
|
'call_platform_api:send_chat_action',
|
||||||
|
|||||||
Reference in New Issue
Block a user