Skip to content

Commit 8ebf34d

Browse files
committed
chore: re-gen services for new unit test code
1 parent f0e73dd commit 8ebf34d

File tree

3 files changed

+437
-18
lines changed

3 files changed

+437
-18
lines changed

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ jproperties
22
requests>=2.0,<3.0
33
python_dateutil>=2.5.3
44
websocket-client==0.48.0
5-
ibm_cloud_sdk_core>=1.7.1
5+
ibm_cloud_sdk_core>=2.0.0,<3.0.0

test/unit/test_global_search_v2.py

Lines changed: 115 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ def test_search_all_params(self):
7272
account_id=account_id,
7373
limit=limit,
7474
timeout=timeout,
75-
sort=sort
75+
sort=sort,
76+
headers={}
7677
)
7778

7879
# Check for correct operation
@@ -87,9 +88,9 @@ def test_search_all_params(self):
8788
assert 'sort={}'.format(','.join(sort)) in query_string
8889
# Validate body params
8990
req_body = json.loads(str(responses.calls[0].request.body, 'utf-8'))
90-
assert req_body['query'] == query
91-
assert req_body['fields'] == fields
92-
assert req_body['search_cursor'] == search_cursor
91+
assert req_body['query'] == 'testString'
92+
assert req_body['fields'] == ['testString']
93+
assert req_body['search_cursor'] == 'testString'
9394

9495

9596
#--------------------------------------------------------
@@ -116,16 +117,17 @@ def test_search_required_params(self):
116117
query=query,
117118
fields=fields,
118119
search_cursor=search_cursor,
120+
headers={}
119121
)
120122

121123
# Check for correct operation
122124
assert len(responses.calls) == 1
123125
assert response.status_code == 200
124126
# Validate body params
125127
req_body = json.loads(str(responses.calls[0].request.body, 'utf-8'))
126-
assert req_body['query'] == query
127-
assert req_body['fields'] == fields
128-
assert req_body['search_cursor'] == search_cursor
128+
assert req_body['query'] == 'testString'
129+
assert req_body['fields'] == ['testString']
130+
assert req_body['search_cursor'] == 'testString'
129131

130132

131133
# endregion
@@ -171,3 +173,109 @@ def test_get_supported_types_all_params(self):
171173
# End of Service: ResourceTypes
172174
##############################################################################
173175

176+
177+
##############################################################################
178+
# Start of Model Tests
179+
##############################################################################
180+
# region
181+
#-----------------------------------------------------------------------------
182+
# Test Class for ResultItem
183+
#-----------------------------------------------------------------------------
184+
class TestResultItem():
185+
186+
#--------------------------------------------------------
187+
# Test serialization/deserialization for ResultItem
188+
#--------------------------------------------------------
189+
def test_result_item_serialization(self):
190+
191+
# Construct a json representation of a ResultItem model
192+
result_item_model_json = {}
193+
result_item_model_json['crn'] = 'testString'
194+
result_item_model_json['foo'] = { 'foo': 'bar' }
195+
196+
# Construct a model instance of ResultItem by calling from_dict on the json representation
197+
result_item_model = ResultItem.from_dict(result_item_model_json)
198+
assert result_item_model != False
199+
200+
# Construct a model instance of ResultItem by calling from_dict on the json representation
201+
result_item_model_dict = ResultItem.from_dict(result_item_model_json).__dict__
202+
result_item_model2 = ResultItem(**result_item_model_dict)
203+
204+
# Verify the model instances are equivalent
205+
assert result_item_model == result_item_model2
206+
207+
# Convert model instance back to dict and verify no loss of data
208+
result_item_model_json2 = result_item_model.to_dict()
209+
assert result_item_model_json2 == result_item_model_json
210+
211+
#-----------------------------------------------------------------------------
212+
# Test Class for ScanResult
213+
#-----------------------------------------------------------------------------
214+
class TestScanResult():
215+
216+
#--------------------------------------------------------
217+
# Test serialization/deserialization for ScanResult
218+
#--------------------------------------------------------
219+
def test_scan_result_serialization(self):
220+
221+
# Construct dict forms of any model objects needed in order to build this model.
222+
223+
result_item_model = {} # ResultItem
224+
result_item_model['crn'] = 'testString'
225+
result_item_model['foo'] = { 'foo': 'bar' }
226+
227+
# Construct a json representation of a ScanResult model
228+
scan_result_model_json = {}
229+
scan_result_model_json['search_cursor'] = 'testString'
230+
scan_result_model_json['limit'] = 36.0
231+
scan_result_model_json['items'] = [result_item_model]
232+
233+
# Construct a model instance of ScanResult by calling from_dict on the json representation
234+
scan_result_model = ScanResult.from_dict(scan_result_model_json)
235+
assert scan_result_model != False
236+
237+
# Construct a model instance of ScanResult by calling from_dict on the json representation
238+
scan_result_model_dict = ScanResult.from_dict(scan_result_model_json).__dict__
239+
scan_result_model2 = ScanResult(**scan_result_model_dict)
240+
241+
# Verify the model instances are equivalent
242+
assert scan_result_model == scan_result_model2
243+
244+
# Convert model instance back to dict and verify no loss of data
245+
scan_result_model_json2 = scan_result_model.to_dict()
246+
assert scan_result_model_json2 == scan_result_model_json
247+
248+
#-----------------------------------------------------------------------------
249+
# Test Class for SupportedTypesList
250+
#-----------------------------------------------------------------------------
251+
class TestSupportedTypesList():
252+
253+
#--------------------------------------------------------
254+
# Test serialization/deserialization for SupportedTypesList
255+
#--------------------------------------------------------
256+
def test_supported_types_list_serialization(self):
257+
258+
# Construct a json representation of a SupportedTypesList model
259+
supported_types_list_model_json = {}
260+
supported_types_list_model_json['supported_types'] = ['testString']
261+
262+
# Construct a model instance of SupportedTypesList by calling from_dict on the json representation
263+
supported_types_list_model = SupportedTypesList.from_dict(supported_types_list_model_json)
264+
assert supported_types_list_model != False
265+
266+
# Construct a model instance of SupportedTypesList by calling from_dict on the json representation
267+
supported_types_list_model_dict = SupportedTypesList.from_dict(supported_types_list_model_json).__dict__
268+
supported_types_list_model2 = SupportedTypesList(**supported_types_list_model_dict)
269+
270+
# Verify the model instances are equivalent
271+
assert supported_types_list_model == supported_types_list_model2
272+
273+
# Convert model instance back to dict and verify no loss of data
274+
supported_types_list_model_json2 = supported_types_list_model.to_dict()
275+
assert supported_types_list_model_json2 == supported_types_list_model_json
276+
277+
278+
# endregion
279+
##############################################################################
280+
# End of Model Tests
281+
##############################################################################

0 commit comments

Comments
 (0)