Skip to content

Commit a37d239

Browse files
committed
fixed tests
1 parent 2ae4cee commit a37d239

File tree

3 files changed

+26
-16
lines changed

3 files changed

+26
-16
lines changed

azure-functions-extension-base/azure/functions/extension/base/utils.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -250,11 +250,6 @@ def get_raw_bindings(indexed_function, input_types):
250250
bindings_logs = {}
251251
for b in indexed_function._bindings:
252252
dict_repr, logs = Binding.get_dict_repr(b, input_types)
253-
binding_dict_repr.append(json.dumps(dict_repr, cls=StringifyEnumJsonEncoder))
253+
binding_dict_repr.append(json.dumps(dict_repr, cls=StringifyEnumJsonEncoder))
254254
bindings_logs.update(logs)
255255
return binding_dict_repr, bindings_logs
256-
257-
# return [
258-
# json.dumps(Binding.get_dict_repr(b, input_types), cls=StringifyEnumJsonEncoder)
259-
# for b in indexed_function._bindings
260-
# ]

azure-functions-extension-base/tests/test_meta.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ class MockIndexedFunction:
146146
_bindings = {}
147147
_trigger = None
148148

149-
self.assertEqual(registry.get_raw_bindings(MockIndexedFunction, []), [])
149+
self.assertEqual(registry.get_raw_bindings(MockIndexedFunction, []), ([], {}))
150150

151151
self.assertFalse(registry.check_supported_type(None))
152152
self.assertFalse(registry.check_supported_type("hello"))

azure-functions-extension-base/tests/test_utils.py

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,9 @@ def test_get_dict_repr_sdk(self):
5656
# Create test indexed_function
5757
mock_indexed_functions = MockFunction(bindings=[mock_blob])
5858

59-
dict_repr = utils.get_raw_bindings(mock_indexed_functions,
60-
mock_input_types)
59+
dict_repr, logs = utils.get_raw_bindings(
60+
mock_indexed_functions, mock_input_types
61+
)
6162
self.assertEqual(
6263
dict_repr,
6364
[
@@ -68,6 +69,8 @@ def test_get_dict_repr_sdk(self):
6869
],
6970
)
7071

72+
self.assertEqual(logs, {"client": (sdkType.SdkType, "True")})
73+
7174
def test_get_dict_repr_non_sdk(self):
7275
# Create mock blob
7376
meta._ConverterMeta._bindings = {"blob"}
@@ -88,7 +91,9 @@ def test_get_dict_repr_non_sdk(self):
8891
# Create test indexed_function
8992
mock_indexed_functions = MockFunction(bindings=[mock_blob])
9093

91-
dict_repr = utils.get_raw_bindings(mock_indexed_functions, mock_input_types)
94+
dict_repr, logs = utils.get_raw_bindings(
95+
mock_indexed_functions, mock_input_types
96+
)
9297
self.assertEqual(
9398
dict_repr,
9499
[
@@ -98,6 +103,7 @@ def test_get_dict_repr_non_sdk(self):
98103
'{"SupportsDeferredBinding": false}}'
99104
],
100105
)
106+
self.assertEqual(logs, {"blob": (bytes, "False")})
101107

102108
def test_get_dict_repr_binding_name_none(self):
103109
# Create mock blob
@@ -126,14 +132,19 @@ def test_get_dict_repr_binding_name_none(self):
126132
# Create test indexed_function
127133
mock_indexed_functions = MockFunction(bindings=[mock_blob, mock_http])
128134

129-
dict_repr = utils.get_raw_bindings(mock_indexed_functions, mock_input_types)
135+
dict_repr, logs = utils.get_raw_bindings(
136+
mock_indexed_functions, mock_input_types
137+
)
130138
self.assertEqual(
131139
dict_repr,
132-
['{"direction": "IN", "dataType": null, "type": "blob", '
133-
'"properties": {"SupportsDeferredBinding": false}}',
134-
'{"direction": "OUT", "dataType": null, "type": "httpResponse", '
135-
'"properties": {"SupportsDeferredBinding": false}}'],
140+
[
141+
'{"direction": "IN", "dataType": null, "type": "blob", '
142+
'"properties": {"SupportsDeferredBinding": false}}',
143+
'{"direction": "OUT", "dataType": null, "type": "httpResponse", '
144+
'"properties": {"SupportsDeferredBinding": false}}',
145+
],
136146
)
147+
self.assertEqual(logs, {"$return": (None, "False"), "blob": (bytes, "False")})
137148

138149
def test_get_dict_repr_init_params(self):
139150
# Create mock blob
@@ -158,7 +169,9 @@ def test_get_dict_repr_init_params(self):
158169
# Create test indexed_function
159170
mock_indexed_functions = MockFunction(bindings=[mock_blob])
160171

161-
dict_repr = utils.get_raw_bindings(mock_indexed_functions, mock_input_types)
172+
dict_repr, logs = utils.get_raw_bindings(
173+
mock_indexed_functions, mock_input_types
174+
)
162175
self.assertEqual(
163176
dict_repr,
164177
[
@@ -168,6 +181,8 @@ def test_get_dict_repr_init_params(self):
168181
],
169182
)
170183

184+
self.assertEqual(logs, {"client": (sdkType.SdkType, "True")})
185+
171186
def test_binding_data_type(self):
172187
mock_blob = utils.Binding(
173188
name="blob",

0 commit comments

Comments
 (0)