Skip to content

Commit fb3ca9c

Browse files
committed
feat(Discovery): New methods for gateway configurations
1 parent 8d03abb commit fb3ca9c

File tree

3 files changed

+394
-0
lines changed

3 files changed

+394
-0
lines changed

test/integration/test_discovery_v1.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,3 +235,27 @@ def test_stopword_operations(self):
235235
self.collection_id
236236
).get_result()
237237
assert delete_stopword_list_result is None
238+
239+
def test_gateway_configuration(self):
240+
create_gateway_result = self.discovery.create_gateway(
241+
self.environment_id,
242+
'test-gateway-configuration-python'
243+
).get_result()
244+
assert create_gateway_result['gateway_id'] is not None
245+
246+
get_gateway_result = self.discovery.get_gateway(
247+
self.environment_id,
248+
create_gateway_result['gateway_id']
249+
).get_result()
250+
assert get_gateway_result is not None
251+
252+
list_gateways_result = self.discovery.list_gateways(
253+
self.environment_id
254+
).get_result()
255+
assert list_gateways_result is not None
256+
257+
delete_gateways_result = self.discovery.delete_gateway(
258+
self.environment_id,
259+
create_gateway_result['gateway_id']
260+
).get_result()
261+
assert delete_gateways_result is not None

test/unit/test_discovery_v1.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1241,3 +1241,50 @@ def test_stopword_operations():
12411241
assert responses.calls[1].response.content is ''
12421242

12431243
assert len(responses.calls) == 2
1244+
1245+
@responses.activate
1246+
def test_gateway_configuration():
1247+
discovery_gateway_url = urljoin(base_discovery_url, 'environments/envid/gateways')
1248+
1249+
gateway_details = {
1250+
"status": "idle",
1251+
"token_id": "9GnaCreixek_prod_ng",
1252+
"token": "4FByv9Mmd79x6c",
1253+
"name": "test-gateway-configuration-python",
1254+
"gateway_id": "gateway_id"
1255+
}
1256+
1257+
iam_url = "https://iam.bluemix.net/identity/token"
1258+
iam_token_response = """{
1259+
"access_token": "oAeisG8yqPY7sFR_x66Z15",
1260+
"token_type": "Bearer",
1261+
"expires_in": 3600,
1262+
"expiration": 1524167011,
1263+
"refresh_token": "jy4gl91BQ"
1264+
}"""
1265+
responses.add(responses.POST, url=iam_url, body=iam_token_response, status=200)
1266+
responses.add(responses.GET, "{0}/{1}?version=2016-11-07".format(discovery_gateway_url, 'gateway_id'),
1267+
body=json.dumps(gateway_details),
1268+
status=200,
1269+
content_type='application/json')
1270+
responses.add(responses.POST, "{0}?version=2016-11-07".format(discovery_gateway_url),
1271+
body=json.dumps(gateway_details),
1272+
status=200,
1273+
content_type='application/json')
1274+
responses.add(responses.GET, "{0}?version=2016-11-07".format(discovery_gateway_url),
1275+
body=json.dumps({'gateways': [gateway_details]}),
1276+
status=200,
1277+
content_type='application/json')
1278+
responses.add(responses.DELETE, "{0}/{1}?version=2016-11-07".format(discovery_gateway_url, 'gateway_id'),
1279+
body=json.dumps({'gateway_id': 'gateway_id', 'status': 'deleted'}),
1280+
status=200,
1281+
content_type='application/json')
1282+
1283+
discovery = watson_developer_cloud.DiscoveryV1('2016-11-07',
1284+
iam_apikey='iam_apikey')
1285+
1286+
discovery.create_gateway('envid', 'gateway_id')
1287+
discovery.list_gateways('envid')
1288+
discovery.get_gateway('envid', 'gateway_id')
1289+
discovery.delete_gateway(environment_id='envid', gateway_id='gateway_id')
1290+
assert len(responses.calls) == 8

0 commit comments

Comments
 (0)