Skip to content

Commit 5704d6b

Browse files
Greyvendclaude
andcommitted
REVAI-4573: Add tests for source_config migration and verbatim fix
TDD red phase: tests expect source_config instead of media_url in STT payload, verbatim=False to be included, and media_url/source_config conflict to raise ValueError. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent e36130e commit 5704d6b

3 files changed

Lines changed: 75 additions & 4 deletions

File tree

tests/test_async_summarization.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def test_submit_source_url(self, mock_session, make_mock_response):
112112
"POST",
113113
JOBS_URL,
114114
json={
115-
'media_url': 'https://example.com/test.mp3',
115+
'source_config': {'url': 'https://example.com/test.mp3'},
116116
'language': 'en',
117117
'summarization_config': {
118118
'prompt': "Try to summarize this transcript as good as you possibly can",

tests/test_async_translation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def test_submit_source_url(self, mock_session, make_mock_response):
147147
"POST",
148148
JOBS_URL,
149149
json={
150-
'media_url': 'https://example.com/test.mp3',
150+
'source_config': {'url': 'https://example.com/test.mp3'},
151151
'language': 'en',
152152
'translation_config': {
153153
'target_languages': [

tests/test_job.py

Lines changed: 73 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ def test_submit_job_url_with_success(self, mock_session, make_mock_response):
162162
"POST",
163163
JOBS_URL,
164164
json={
165-
'media_url': SOURCE_URL,
165+
'source_config': {'url': SOURCE_URL},
166166
'callback_url': NOTIFICATION_URL,
167167
'metadata': METADATA,
168168
'skip_diarization': True,
@@ -276,14 +276,85 @@ def test_submit_job_url_with_human_transcription_and_success(self, mock_session,
276276
'POST',
277277
JOBS_URL,
278278
json={
279-
'media_url': SOURCE_URL,
279+
'source_config': {'url': SOURCE_URL},
280280
'transcriber': 'human',
281281
'verbatim': True,
282282
'segments_to_transcribe': segments,
283283
'speaker_names': [{'display_name': 'Kyle Bridburg'}]
284284
},
285285
headers=client.default_headers)
286286

287+
def test_submit_job_url_with_media_url_and_source_config_conflict(self, mock_session):
288+
"""Passing both media_url and source_config should raise ValueError."""
289+
client = RevAiAPIClient(TOKEN)
290+
291+
with pytest.raises(ValueError, match='media_url is not compatible with source_config'):
292+
client.submit_job_url(
293+
media_url=SOURCE_URL,
294+
source_config=SOURCE_CONFIG
295+
)
296+
297+
def test_submit_job_url_verbatim_false(self, mock_session, make_mock_response):
298+
"""verbatim=False should be included in payload."""
299+
data = {
300+
'id': JOB_ID,
301+
'status': 'in_progress',
302+
'created_on': CREATED_ON,
303+
}
304+
response = make_mock_response(url=JOB_ID_URL, json_data=data)
305+
mock_session.request.return_value = response
306+
client = RevAiAPIClient(TOKEN)
307+
308+
client.submit_job_url(SOURCE_URL, verbatim=False)
309+
310+
mock_session.request.assert_called_once_with(
311+
'POST',
312+
JOBS_URL,
313+
json={
314+
'source_config': {'url': SOURCE_URL},
315+
'verbatim': False,
316+
},
317+
headers=client.default_headers)
318+
319+
def test_submit_job_url_verbatim_true(self, mock_session, make_mock_response):
320+
"""verbatim=True should be included in payload."""
321+
data = {
322+
'id': JOB_ID,
323+
'status': 'in_progress',
324+
'created_on': CREATED_ON,
325+
}
326+
response = make_mock_response(url=JOB_ID_URL, json_data=data)
327+
mock_session.request.return_value = response
328+
client = RevAiAPIClient(TOKEN)
329+
330+
client.submit_job_url(SOURCE_URL, verbatim=True)
331+
332+
mock_session.request.assert_called_once_with(
333+
'POST',
334+
JOBS_URL,
335+
json={
336+
'source_config': {'url': SOURCE_URL},
337+
'verbatim': True,
338+
},
339+
headers=client.default_headers)
340+
341+
def test_submit_job_url_verbatim_none(self, mock_session, make_mock_response):
342+
"""verbatim=None (default) should NOT be included in payload."""
343+
data = {
344+
'id': JOB_ID,
345+
'status': 'in_progress',
346+
'created_on': CREATED_ON,
347+
}
348+
response = make_mock_response(url=JOB_ID_URL, json_data=data)
349+
mock_session.request.return_value = response
350+
client = RevAiAPIClient(TOKEN)
351+
352+
client.submit_job_url(SOURCE_URL)
353+
354+
call_kwargs = mock_session.request.call_args
355+
payload = call_kwargs[1]['json'] if 'json' in call_kwargs[1] else call_kwargs[0][2]
356+
assert 'verbatim' not in payload
357+
287358
def test_submit_job_local_file_with_success(self, mocker, mock_session, make_mock_response):
288359
created_on = '2018-05-05T23:23:22.29Z'
289360
data = {

0 commit comments

Comments
 (0)