@@ -1173,3 +1173,45 @@ def test_events_and_feedback():
11731173 assert responses .calls [13 ].response .json () == log_query_response
11741174
11751175 assert len (responses .calls ) == 14
1176+
1177+ @responses .activate
1178+ def test_tokenization_dictionary ():
1179+ url = 'https://gateway.watsonplatform.net/discovery/api/v1/environments/envid/collections/colid/word_lists/tokenization_dictionary?version=2017-11-07'
1180+ responses .add (
1181+ responses .POST ,
1182+ url ,
1183+ body = '{"status": "pending"}' ,
1184+ status = 200 ,
1185+ content_type = 'application_json' )
1186+ responses .add (
1187+ responses .DELETE ,
1188+ url ,
1189+ body = '{"status": "pending"}' ,
1190+ status = 200 )
1191+ responses .add (
1192+ responses .GET ,
1193+ url ,
1194+ body = '{"status": "pending", "type":"tokenization_dictionary"}' ,
1195+ status = 200 ,
1196+ content_type = 'application_json' )
1197+
1198+ discovery = watson_developer_cloud .DiscoveryV1 ('2017-11-07' , username = "username" , password = "password" )
1199+
1200+ tokenization_rules = [
1201+ {
1202+ 'text' : 'token' ,
1203+ 'tokens' : ['token 1' , 'token 2' ],
1204+ 'readings' : ['reading 1' , 'reading 2' ],
1205+ 'part_of_speech' : 'noun' ,
1206+ }
1207+ ]
1208+ discovery .create_tokenization_dictionary ('envid' , 'colid' , tokenization_rules )
1209+ assert responses .calls [0 ].response .json () == {"status" : "pending" }
1210+
1211+ discovery .get_tokenization_dictionary_status ('envid' , 'colid' )
1212+ assert responses .calls [1 ].response .json () == {"status" : "pending" , "type" :"tokenization_dictionary" }
1213+
1214+ discovery .delete_tokenization_dictionary ('envid' , 'colid' )
1215+ assert responses .calls [2 ].response .status_code is 200
1216+
1217+ assert len (responses .calls ) == 3
0 commit comments