forked from BasedHardware/omi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_app_tool_method_null.py
More file actions
35 lines (25 loc) · 1.19 KB
/
Copy pathtest_app_tool_method_null.py
File metadata and controls
35 lines (25 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
"""Regression test: a manifest tool with method=null must not crash validation.
utils.apps._validate_tool_definition normalizes an app-manifest tool. It guarded name /
description / endpoint against non-string values but built
`'method': typed_tool.get('method', 'POST').upper()`. dict.get's default applies only to
ABSENT keys, so a present-but-null method (`"method": null`) made get return None and
None.upper() raised AttributeError, aborting manifest tool validation. method now falls back
to 'POST' for a null or empty value.
"""
from utils.apps import _validate_tool_definition
def _tool(**overrides):
t = {'name': 't', 'description': 'd', 'endpoint': 'https://e'}
t.update(overrides)
return t
def test_null_method_defaults_to_post():
result = _validate_tool_definition(_tool(method=None))
assert result is not None
assert result['method'] == 'POST'
def test_absent_method_defaults_to_post():
result = _validate_tool_definition(_tool())
assert result is not None
assert result['method'] == 'POST'
def test_string_method_is_uppercased():
result = _validate_tool_definition(_tool(method='get'))
assert result is not None
assert result['method'] == 'GET'