|
4 | 4 |
|
5 | 5 | from a2a.types import ( |
6 | 6 | DataPart, |
7 | | - FilePart, |
8 | | - FileWithBytes, |
9 | | - FileWithUri, |
10 | 7 | Message, |
11 | 8 | Part, |
12 | 9 | Role, |
13 | 10 | TextPart, |
14 | 11 | ) |
15 | 12 | from a2a.utils.message import ( |
16 | | - get_data_parts, |
17 | | - get_file_parts, |
18 | 13 | get_message_text, |
19 | | - get_text_parts, |
20 | 14 | new_agent_parts_message, |
21 | 15 | new_agent_text_message, |
22 | 16 | ) |
@@ -147,177 +141,6 @@ def test_new_agent_parts_message(self): |
147 | 141 | assert message.message_id == 'abcdefab-cdef-abcd-efab-cdefabcdefab' |
148 | 142 |
|
149 | 143 |
|
150 | | -class TestGetTextParts: |
151 | | - def test_get_text_parts_single_text_part(self): |
152 | | - # Setup |
153 | | - parts = [Part(root=TextPart(text='Hello world'))] |
154 | | - |
155 | | - # Exercise |
156 | | - result = get_text_parts(parts) |
157 | | - |
158 | | - # Verify |
159 | | - assert result == ['Hello world'] |
160 | | - |
161 | | - def test_get_text_parts_multiple_text_parts(self): |
162 | | - # Setup |
163 | | - parts = [ |
164 | | - Part(root=TextPart(text='First part')), |
165 | | - Part(root=TextPart(text='Second part')), |
166 | | - Part(root=TextPart(text='Third part')), |
167 | | - ] |
168 | | - |
169 | | - # Exercise |
170 | | - result = get_text_parts(parts) |
171 | | - |
172 | | - # Verify |
173 | | - assert result == ['First part', 'Second part', 'Third part'] |
174 | | - |
175 | | - def test_get_text_parts_empty_list(self): |
176 | | - # Setup |
177 | | - parts = [] |
178 | | - |
179 | | - # Exercise |
180 | | - result = get_text_parts(parts) |
181 | | - |
182 | | - # Verify |
183 | | - assert result == [] |
184 | | - |
185 | | - |
186 | | -class TestGetDataParts: |
187 | | - def test_get_data_parts_single_data_part(self): |
188 | | - # Setup |
189 | | - parts = [Part(root=DataPart(data={'key': 'value'}))] |
190 | | - |
191 | | - # Exercise |
192 | | - result = get_data_parts(parts) |
193 | | - |
194 | | - # Verify |
195 | | - assert result == [{'key': 'value'}] |
196 | | - |
197 | | - def test_get_data_parts_multiple_data_parts(self): |
198 | | - # Setup |
199 | | - parts = [ |
200 | | - Part(root=DataPart(data={'key1': 'value1'})), |
201 | | - Part(root=DataPart(data={'key2': 'value2'})), |
202 | | - ] |
203 | | - |
204 | | - # Exercise |
205 | | - result = get_data_parts(parts) |
206 | | - |
207 | | - # Verify |
208 | | - assert result == [{'key1': 'value1'}, {'key2': 'value2'}] |
209 | | - |
210 | | - def test_get_data_parts_mixed_parts(self): |
211 | | - # Setup |
212 | | - parts = [ |
213 | | - Part(root=TextPart(text='some text')), |
214 | | - Part(root=DataPart(data={'key1': 'value1'})), |
215 | | - Part(root=DataPart(data={'key2': 'value2'})), |
216 | | - ] |
217 | | - |
218 | | - # Exercise |
219 | | - result = get_data_parts(parts) |
220 | | - |
221 | | - # Verify |
222 | | - assert result == [{'key1': 'value1'}, {'key2': 'value2'}] |
223 | | - |
224 | | - def test_get_data_parts_no_data_parts(self): |
225 | | - # Setup |
226 | | - parts = [ |
227 | | - Part(root=TextPart(text='some text')), |
228 | | - ] |
229 | | - |
230 | | - # Exercise |
231 | | - result = get_data_parts(parts) |
232 | | - |
233 | | - # Verify |
234 | | - assert result == [] |
235 | | - |
236 | | - def test_get_data_parts_empty_list(self): |
237 | | - # Setup |
238 | | - parts = [] |
239 | | - |
240 | | - # Exercise |
241 | | - result = get_data_parts(parts) |
242 | | - |
243 | | - # Verify |
244 | | - assert result == [] |
245 | | - |
246 | | - |
247 | | -class TestGetFileParts: |
248 | | - def test_get_file_parts_single_file_part(self): |
249 | | - # Setup |
250 | | - file_with_uri = FileWithUri( |
251 | | - uri='file://path/to/file', mimeType='text/plain' |
252 | | - ) |
253 | | - parts = [Part(root=FilePart(file=file_with_uri))] |
254 | | - |
255 | | - # Exercise |
256 | | - result = get_file_parts(parts) |
257 | | - |
258 | | - # Verify |
259 | | - assert result == [file_with_uri] |
260 | | - |
261 | | - def test_get_file_parts_multiple_file_parts(self): |
262 | | - # Setup |
263 | | - file_with_uri1 = FileWithUri( |
264 | | - uri='file://path/to/file1', mime_type='text/plain' |
265 | | - ) |
266 | | - file_with_bytes = FileWithBytes( |
267 | | - bytes='ZmlsZSBjb250ZW50', |
268 | | - mime_type='application/octet-stream', # 'file content' |
269 | | - ) |
270 | | - parts = [ |
271 | | - Part(root=FilePart(file=file_with_uri1)), |
272 | | - Part(root=FilePart(file=file_with_bytes)), |
273 | | - ] |
274 | | - |
275 | | - # Exercise |
276 | | - result = get_file_parts(parts) |
277 | | - |
278 | | - # Verify |
279 | | - assert result == [file_with_uri1, file_with_bytes] |
280 | | - |
281 | | - def test_get_file_parts_mixed_parts(self): |
282 | | - # Setup |
283 | | - file_with_uri = FileWithUri( |
284 | | - uri='file://path/to/file', mime_type='text/plain' |
285 | | - ) |
286 | | - parts = [ |
287 | | - Part(root=TextPart(text='some text')), |
288 | | - Part(root=FilePart(file=file_with_uri)), |
289 | | - ] |
290 | | - |
291 | | - # Exercise |
292 | | - result = get_file_parts(parts) |
293 | | - |
294 | | - # Verify |
295 | | - assert result == [file_with_uri] |
296 | | - |
297 | | - def test_get_file_parts_no_file_parts(self): |
298 | | - # Setup |
299 | | - parts = [ |
300 | | - Part(root=TextPart(text='some text')), |
301 | | - Part(root=DataPart(data={'key': 'value'})), |
302 | | - ] |
303 | | - |
304 | | - # Exercise |
305 | | - result = get_file_parts(parts) |
306 | | - |
307 | | - # Verify |
308 | | - assert result == [] |
309 | | - |
310 | | - def test_get_file_parts_empty_list(self): |
311 | | - # Setup |
312 | | - parts = [] |
313 | | - |
314 | | - # Exercise |
315 | | - result = get_file_parts(parts) |
316 | | - |
317 | | - # Verify |
318 | | - assert result == [] |
319 | | - |
320 | | - |
321 | 144 | class TestGetMessageText: |
322 | 145 | def test_get_message_text_single_part(self): |
323 | 146 | # Setup |
|
0 commit comments