@@ -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