@@ -284,7 +284,30 @@ final class InternalPartTests: XCTestCase {
284
284
XCTAssertEqual ( functionResponse. response, [ " output " : . string( " someValue " ) ] )
285
285
}
286
286
287
- func testDecodeExecutableCodePart( ) throws {
287
+ func testDecodeExecutableCodePartWithThought( ) throws {
288
+ let json = """
289
+ {
290
+ " executableCode " : {
291
+ " language " : " PYTHON " ,
292
+ " code " : " print('hello') "
293
+ },
294
+ " thought " : true
295
+ }
296
+ """
297
+ let jsonData = try XCTUnwrap ( json. data ( using: . utf8) )
298
+
299
+ let part = try decoder. decode ( InternalPart . self, from: jsonData)
300
+
301
+ XCTAssertEqual ( part. isThought, true )
302
+ guard case let . executableCode( executableCode) = part. data else {
303
+ XCTFail ( " Decoded part is not an executableCode part. " )
304
+ return
305
+ }
306
+ XCTAssertEqual ( executableCode. language, . init( kind: . python) )
307
+ XCTAssertEqual ( executableCode. code, " print('hello') " )
308
+ }
309
+
310
+ func testDecodeExecutableCodePartWithoutThought( ) throws {
288
311
let json = """
289
312
{
290
313
" executableCode " : {
@@ -367,7 +390,30 @@ final class InternalPartTests: XCTestCase {
367
390
XCTAssertNil ( executableCode. code)
368
391
}
369
392
370
- func testDecodeCodeExecutionResultPart( ) throws {
393
+ func testDecodeCodeExecutionResultPartWithThought( ) throws {
394
+ let json = """
395
+ {
396
+ " codeExecutionResult " : {
397
+ " outcome " : " OUTCOME_OK " ,
398
+ " output " : " hello "
399
+ },
400
+ " thought " : true
401
+ }
402
+ """
403
+ let jsonData = try XCTUnwrap ( json. data ( using: . utf8) )
404
+
405
+ let part = try decoder. decode ( InternalPart . self, from: jsonData)
406
+
407
+ XCTAssertEqual ( part. isThought, true )
408
+ guard case let . codeExecutionResult( codeExecutionResult) = part. data else {
409
+ XCTFail ( " Decoded part is not a codeExecutionResult part. " )
410
+ return
411
+ }
412
+ XCTAssertEqual ( codeExecutionResult. outcome, . init( kind: . ok) )
413
+ XCTAssertEqual ( codeExecutionResult. output, " hello " )
414
+ }
415
+
416
+ func testDecodeCodeExecutionResultPartWithoutThought( ) throws {
371
417
let json = """
372
418
{
373
419
" codeExecutionResult " : {
0 commit comments