Skip to content

Commit 3588edf

Browse files
authored
Merge pull request #9 from kleinjoshuaa/import_attributes_from_json
added test
2 parents f496fef + f7160b0 commit 3588edf

File tree

2 files changed

+50
-2
lines changed

2 files changed

+50
-2
lines changed

splitapiclient/microclients/attribute_microclient.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class AttributeMicroClient:
3131
'query_string': [],
3232
'response': True,
3333
},
34-
'import_from_json': {
34+
'import_attributes_from_json': {
3535
'method': 'POST',
3636
'url_template': 'schema/ws/{workspaceId}/trafficTypes/{trafficTypeId}/attribute:bulk',
3737
'headers': [{
@@ -155,7 +155,7 @@ def import_attributes_from_json(self, workspaceId, trafficTypeId, data):
155155
:returns: bool
156156
'''
157157
res = self._http_client.make_request(
158-
self._endpoint['import_from_json'],
158+
self._endpoint['import_attributes_from_json'],
159159
body=data,
160160
workspaceId = workspaceId,
161161
trafficTypeId = trafficTypeId,

splitapiclient/tests/resources/test_traffic_type.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,3 +395,51 @@ def test_add_identities(self, mocker):
395395
assert [s.to_dict() for s in res3.successful] == data
396396
assert isinstance(res3.failed, list)
397397
assert isinstance(res3.metadata, dict)
398+
399+
def test_import_JSON(self, mocker):
400+
'''
401+
'''
402+
data = {
403+
'id': 'a1',
404+
'trafficTypeId': '1',
405+
'displayName': 'dn1',
406+
'isSearchable': None,
407+
'dataType': 'string',
408+
'description': 'd1',
409+
'workspaceId': 'ws_id'
410+
}
411+
http_client_mock = mocker.Mock(spec=BaseHttpClient)
412+
http_client_mock.make_request.return_value = data
413+
tt1 = TrafficType(
414+
{
415+
'id': '1',
416+
'displayAttributeId': 'asd',
417+
'name': 'n1',
418+
},
419+
'ws_id',
420+
http_client_mock
421+
)
422+
attrib_data = [ {
423+
"id": "anAttribute2",
424+
"displayName": "An Attribute2",
425+
"description": "my description here",
426+
"dataType": "string",
427+
"suggestedValues": [
428+
"suggested",
429+
"values"
430+
]
431+
} ]
432+
433+
434+
tt1.import_attributes_from_json(attrib_data)
435+
436+
437+
http_client_mock.make_request.assert_called_once_with(
438+
AttributeMicroClient._endpoint['import_attributes_from_json'],
439+
body=attrib_data,
440+
workspaceId = data['workspaceId'],
441+
trafficTypeId = data['trafficTypeId']
442+
443+
)
444+
445+

0 commit comments

Comments
 (0)