-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_utils.py
More file actions
86 lines (82 loc) · 3.07 KB
/
test_utils.py
File metadata and controls
86 lines (82 loc) · 3.07 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import unittest
from polyapi.utils import get_type_and_def, rewrite_reserved
OPENAPI_FUNCTION = {
"kind": "function",
"spec": {
"arguments": [
{
"name": "event",
"required": False,
"type": {
"kind": "object",
"schema": {
"$schema": "http://json-schema.org/draft-06/schema#",
"type": "array",
"items": {"$ref": "#/definitions/WebhookEventTypeElement"},
"definitions": {
"WebhookEventTypeElement": {
"type": "object",
"additionalProperties": False,
"properties": {
"title": {"type": "string"},
"manufacturerName": {"type": "string"},
"carType": {"type": "string"},
"id": {"type": "integer"},
},
"required": [
"carType",
"id",
"manufacturerName",
"title",
],
"title": "WebhookEventTypeElement",
}
},
},
},
},
{
"name": "headers",
"required": False,
"type": {"kind": "object", "typeName": "Record<string, any>"},
},
{
"name": "params",
"required": False,
"type": {"kind": "object", "typeName": "Record<string, any>"},
},
{
"name": "polyCustom",
"required": False,
"type": {
"kind": "object",
"properties": [
{
"name": "responseStatusCode",
"type": {"type": "number", "kind": "primitive"},
"required": True,
},
{
"name": "responseContentType",
"type": {"type": "string", "kind": "primitive"},
"required": True,
"nullable": True,
},
],
},
},
],
"returnType": {"kind": "void"},
"synchronous": True,
},
}
class T(unittest.TestCase):
def test_get_type_and_def(self):
arg_type, arg_def = get_type_and_def(OPENAPI_FUNCTION)
self.assertEqual(
arg_type,
"Callable[[List[WebhookEventTypeElement], Dict, Dict, Dict], None]",
)
def test_rewrite_reserved(self):
rv = rewrite_reserved("from")
self.assertEqual(rv, "_from")