@@ -34,25 +34,57 @@ def test_get_transcript_text(self, mock_session, make_mock_response):
3434 mock_session .request .assert_called_once_with ("GET" ,
3535 URL ,
3636 headers = expected_headers )
37+
38+ @pytest .mark .parametrize ('group_channels_by, group_channels_threshold_ms' , [(None , None ), ('sentence' , 5000 ), ('word' , 2000 )])
39+ def test_get_transcript_text (self , mock_session , make_mock_response , group_channels_by , group_channels_threshold_ms ):
40+ data = 'Test'
41+ client = RevAiAPIClient (TOKEN )
42+ expected_headers = {'Accept' : 'text/plain' }
43+ expected_headers .update (client .default_headers )
44+ response = make_mock_response (url = URL , text = data )
45+ mock_session .request .return_value = response
46+ expected_url = URL
47+ if group_channels_by and group_channels_threshold_ms :
48+ expected_url += f"?group_channels_by={ group_channels_by } &group_channels_threshold_ms={ group_channels_threshold_ms } "
49+
50+ res = client .get_transcript_text (JOB_ID , group_channels_by = group_channels_by , group_channels_threshold_ms = group_channels_threshold_ms )
51+
52+ assert res == data
53+ mock_session .request .assert_called_once_with ("GET" ,
54+ expected_url ,
55+ headers = expected_headers )
3756
3857 @pytest .mark .parametrize ('id' , [None , '' ])
3958 def test_get_transcript_text_with_no_job_id (self , id , mock_session ):
4059 with pytest .raises (ValueError , match = 'id_ must be provided' ):
4160 RevAiAPIClient (TOKEN ).get_transcript_text (id )
4261
43- def test_get_transcript_text_as_stream (self , mock_session , make_mock_response ):
62+ @pytest .mark .parametrize (
63+ 'group_channels_by, group_channels_threshold_ms' ,
64+ [(None , None ), ('sentence' , 5000 ), ('word' , 2000 )]
65+ )
66+ def test_get_transcript_text_as_stream (
67+ self ,
68+ mock_session ,
69+ make_mock_response ,
70+ group_channels_by ,
71+ group_channels_threshold_ms
72+ ):
4473 data = 'Test'
4574 client = RevAiAPIClient (TOKEN )
4675 expected_headers = {'Accept' : 'text/plain' }
4776 expected_headers .update (client .default_headers )
4877 response = make_mock_response (url = URL , text = data )
4978 mock_session .request .return_value = response
79+ expected_url = URL
80+ if group_channels_by and group_channels_threshold_ms :
81+ expected_url += f"?group_channels_by={ group_channels_by } &group_channels_threshold_ms={ group_channels_threshold_ms } "
5082
51- res = client .get_transcript_text_as_stream (JOB_ID )
83+ res = client .get_transcript_text_as_stream (JOB_ID , group_channels_by = group_channels_by , group_channels_threshold_ms = group_channels_threshold_ms )
5284
5385 assert res .content == data
5486 mock_session .request .assert_called_once_with ("GET" ,
55- URL ,
87+ expected_url ,
5688 headers = expected_headers ,
5789 stream = True )
5890
@@ -61,7 +93,17 @@ def test_get_transcript_text_as_stream_with_no_job_id(self, id, mock_session):
6193 with pytest .raises (ValueError , match = 'id_ must be provided' ):
6294 RevAiAPIClient (TOKEN ).get_transcript_text_as_stream (id )
6395
64- def test_get_transcript_json (self , mock_session , make_mock_response ):
96+ @pytest .mark .parametrize (
97+ 'group_channels_by, group_channels_threshold_ms' ,
98+ [(None , None ), ('sentence' , 5000 ), ('word' , 2000 )]
99+ )
100+ def test_get_transcript_json (
101+ self ,
102+ mock_session ,
103+ make_mock_response ,
104+ group_channels_by ,
105+ group_channels_threshold_ms
106+ ):
65107 data = {
66108 'monologues' : [{
67109 'speaker' : 1 ,
@@ -80,19 +122,32 @@ def test_get_transcript_json(self, mock_session, make_mock_response):
80122 expected_headers .update (client .default_headers )
81123 response = make_mock_response (url = URL , json_data = data )
82124 mock_session .request .return_value = response
125+ expected_url = URL
126+ if group_channels_by and group_channels_threshold_ms :
127+ expected_url += f"?group_channels_by={ group_channels_by } &group_channels_threshold_ms={ group_channels_threshold_ms } "
83128
84- res = client .get_transcript_json (JOB_ID )
129+ res = client .get_transcript_json (JOB_ID , group_channels_by = group_channels_by , group_channels_threshold_ms = group_channels_threshold_ms )
85130
86131 assert res == expected
87132 mock_session .request .assert_called_once_with (
88- "GET" , URL , headers = expected_headers )
133+ "GET" , expected_url , headers = expected_headers )
89134
90135 @pytest .mark .parametrize ('id' , [None , '' ])
91136 def test_get_transcript_json_with_no_job_id (self , id , mock_session ):
92137 with pytest .raises (ValueError , match = 'id_ must be provided' ):
93138 RevAiAPIClient (TOKEN ).get_transcript_json (id )
94139
95- def test_get_transcript_json_as_stream (self , mock_session , make_mock_response ):
140+ @pytest .mark .parametrize (
141+ 'group_channels_by, group_channels_threshold_ms' ,
142+ [(None , None ), ('sentence' , 5000 ), ('word' , 2000 )]
143+ )
144+ def test_get_transcript_json_as_stream (
145+ self ,
146+ mock_session ,
147+ make_mock_response ,
148+ group_channels_by ,
149+ group_channels_threshold_ms
150+ ):
96151 data = {
97152 'monologues' : [{
98153 'speaker' : 1 ,
@@ -111,19 +166,32 @@ def test_get_transcript_json_as_stream(self, mock_session, make_mock_response):
111166 expected_headers .update (client .default_headers )
112167 response = make_mock_response (url = URL , json_data = data )
113168 mock_session .request .return_value = response
169+ expected_url = URL
170+ if group_channels_by and group_channels_threshold_ms :
171+ expected_url += f"?group_channels_by={ group_channels_by } &group_channels_threshold_ms={ group_channels_threshold_ms } "
114172
115- res = client .get_transcript_json_as_stream (JOB_ID )
173+ res = client .get_transcript_json_as_stream (JOB_ID , group_channels_by = group_channels_by , group_channels_threshold_ms = group_channels_threshold_ms )
116174
117175 assert json .loads (res .content .decode ('utf-8' ).replace ("\' " , "\" " )) == expected
118176 mock_session .request .assert_called_once_with (
119- "GET" , URL , headers = expected_headers , stream = True )
177+ "GET" , expected_url , headers = expected_headers , stream = True )
120178
121179 @pytest .mark .parametrize ('id' , [None , '' ])
122180 def test_get_transcript_json_as_stream_with_no_job_id (self , id , mock_session ):
123181 with pytest .raises (ValueError , match = 'id_ must be provided' ):
124182 RevAiAPIClient (TOKEN ).get_transcript_json_as_stream (id )
125183
126- def test_get_transcript_object_with_success (self , mock_session , make_mock_response ):
184+ @pytest .mark .parametrize (
185+ 'group_channels_by, group_channels_threshold_ms' ,
186+ [(None , None ), ('sentence' , 5000 ), ('word' , 2000 )]
187+ )
188+ def test_get_transcript_object_with_success (
189+ self ,
190+ mock_session ,
191+ make_mock_response ,
192+ group_channels_by ,
193+ group_channels_threshold_ms
194+ ):
127195 data = {
128196 'monologues' : [{
129197 'speaker' : 1 ,
@@ -142,12 +210,15 @@ def test_get_transcript_object_with_success(self, mock_session, make_mock_respon
142210 expected_headers .update (client .default_headers )
143211 response = make_mock_response (url = URL , json_data = data )
144212 mock_session .request .return_value = response
213+ expected_url = URL
214+ if group_channels_by and group_channels_threshold_ms :
215+ expected_url += f"?group_channels_by={ group_channels_by } &group_channels_threshold_ms={ group_channels_threshold_ms } "
145216
146- res = client .get_transcript_object (JOB_ID )
217+ res = client .get_transcript_object (JOB_ID , group_channels_by = group_channels_by , group_channels_threshold_ms = group_channels_threshold_ms )
147218
148219 assert res == expected
149220 mock_session .request .assert_called_once_with (
150- "GET" , URL , headers = expected_headers )
221+ "GET" , expected_url , headers = expected_headers )
151222
152223 @pytest .mark .parametrize ('id' , [None , '' ])
153224 def test_get_transcript_object_with_no_job_id (self , id , mock_session ):
0 commit comments