@@ -17,10 +17,12 @@ async def test_mock_activity_trigger(self):
17
17
18
18
_ , r = await host .invoke_function (
19
19
'activity_trigger' , [
20
+ # According to Durable Python
21
+ # Activity Trigger's input must be json serializable
20
22
protos .ParameterBinding (
21
23
name = 'input' ,
22
24
data = protos .TypedData (
23
- string = 'test'
25
+ string = 'test single_word '
24
26
)
25
27
)
26
28
]
@@ -29,7 +31,7 @@ async def test_mock_activity_trigger(self):
29
31
protos .StatusResult .Success )
30
32
self .assertEqual (
31
33
r .response .return_value ,
32
- protos .TypedData (string = ' test' )
34
+ protos .TypedData (json = '" test single_word" ' )
33
35
)
34
36
35
37
async def test_mock_activity_trigger_no_anno (self ):
@@ -44,10 +46,12 @@ async def test_mock_activity_trigger_no_anno(self):
44
46
45
47
_ , r = await host .invoke_function (
46
48
'activity_trigger_no_anno' , [
49
+ # According to Durable Python
50
+ # Activity Trigger's input must be json serializable
47
51
protos .ParameterBinding (
48
52
name = 'input' ,
49
53
data = protos .TypedData (
50
- bytes = b' \x34 \x93 \x04 \x70 '
54
+ string = 'test multiple words '
51
55
)
52
56
)
53
57
]
@@ -56,7 +60,66 @@ async def test_mock_activity_trigger_no_anno(self):
56
60
protos .StatusResult .Success )
57
61
self .assertEqual (
58
62
r .response .return_value ,
59
- protos .TypedData (bytes = b'\x34 \x93 \x04 \x70 ' )
63
+ protos .TypedData (json = '"test multiple words"' )
64
+ )
65
+
66
+ async def test_mock_activity_trigger_dict (self ):
67
+ async with testutils .start_mockhost (
68
+ script_root = self .durable_functions_dir ) as host :
69
+
70
+ func_id , r = await host .load_function ('activity_trigger_dict' )
71
+
72
+ self .assertEqual (r .response .function_id , func_id )
73
+ self .assertEqual (r .response .result .status ,
74
+ protos .StatusResult .Success )
75
+
76
+ _ , r = await host .invoke_function (
77
+ 'activity_trigger_dict' , [
78
+ # According to Durable Python
79
+ # Activity Trigger's input must be json serializable
80
+ protos .ParameterBinding (
81
+ name = 'input' ,
82
+ data = protos .TypedData (
83
+ json = '{"bird": "Crane"}'
84
+ )
85
+ )
86
+ ]
87
+ )
88
+ self .assertEqual (r .response .result .status ,
89
+ protos .StatusResult .Success )
90
+ self .assertEqual (
91
+ r .response .return_value ,
92
+ protos .TypedData (json = '{"bird": "enarC"}' )
93
+ )
94
+
95
+ async def test_mock_activity_trigger_int_to_float (self ):
96
+ async with testutils .start_mockhost (
97
+ script_root = self .durable_functions_dir ) as host :
98
+
99
+ func_id , r = await host .load_function (
100
+ 'activity_trigger_int_to_float' )
101
+
102
+ self .assertEqual (r .response .function_id , func_id )
103
+ self .assertEqual (r .response .result .status ,
104
+ protos .StatusResult .Success )
105
+
106
+ _ , r = await host .invoke_function (
107
+ 'activity_trigger_int_to_float' , [
108
+ # According to Durable Python
109
+ # Activity Trigger's input must be json serializable
110
+ protos .ParameterBinding (
111
+ name = 'input' ,
112
+ data = protos .TypedData (
113
+ json = str (int (10 ))
114
+ )
115
+ )
116
+ ]
117
+ )
118
+ self .assertEqual (r .response .result .status ,
119
+ protos .StatusResult .Success )
120
+ self .assertEqual (
121
+ r .response .return_value ,
122
+ protos .TypedData (json = '-11.0' )
60
123
)
61
124
62
125
async def test_mock_orchestration_trigger (self ):
@@ -83,5 +146,5 @@ async def test_mock_orchestration_trigger(self):
83
146
protos .StatusResult .Success )
84
147
self .assertEqual (
85
148
r .response .return_value ,
86
- protos .TypedData (string = 'Durable functions coming soon :)' )
149
+ protos .TypedData (json = 'Durable functions coming soon :)' )
87
150
)
0 commit comments