Skip to content

Commit c748d10

Browse files
authored
Merge pull request #592 from watson-developer-cloud/codegen/all
Regeneration of python SDK
2 parents 553bc9a + a6f5eb4 commit c748d10

14 files changed

+1509
-288
lines changed

test/integration/test_discovery_v1.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,14 @@ def setUp(self):
2121
collections = self.discovery.list_collections(self.environment_id).get_result()['collections']
2222
self.collection_id = collections[0]['collection_id']
2323

24+
for collection in collections:
25+
if collection['name'] == 'DO-NOT-DELETE-JAPANESE-COLLECTION':
26+
self.collection_id_JP = collection['collection_id']
27+
2428
def tearDown(self):
2529
collections = self.discovery.list_collections(self.environment_id).get_result()['collections']
2630
for collection in collections:
27-
if collection['name'] != 'DO-NOT-DELETE':
31+
if not collection['name'].startswith('DO-NOT-DELETE'):
2832
self.discovery.delete_collection(self.environment_id, collection['collection_id'])
2933

3034
def test_environments(self):
@@ -209,3 +213,11 @@ def test_feedback(self):
209213

210214
response = self.discovery.query_log(count=2).get_result()
211215
assert response is not None
216+
217+
218+
def test_tokenization_dictionary(self):
219+
result = self.discovery.get_tokenization_dictionary_status(
220+
self.environment_id,
221+
self.collection_id_JP
222+
).get_result()
223+
assert result['status'] is not None

test/unit/test_discovery_v1.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

test/unit/test_speech_to_text_v1.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,12 @@ def test_success():
4646
assert request_url == recognize_url
4747
assert responses.calls[1].response.text == recognize_response
4848

49-
assert len(responses.calls) == 2
49+
with open(os.path.join(os.path.dirname(__file__), '../../resources/speech.wav'), 'rb') as audio_file:
50+
speech_to_text.recognize(
51+
audio=audio_file, customization_id='x', content_type='audio/l16; rate=44100')
52+
expected_url = "{0}?customization_id=x".format(recognize_url)
53+
assert expected_url == responses.calls[2].request.url
54+
assert len(responses.calls) == 3
5055

5156

5257
@responses.activate

0 commit comments

Comments
 (0)