@@ -16,7 +16,7 @@ class OpenAITests: XCTestCase {
16
16
17
17
override func setUp( ) async throws {
18
18
let configuration = OpenAI . Configuration ( token: " foo " , organizationIdentifier: " bar " , timeoutInterval: 14 )
19
- self . openAI = OpenAI ( configuration: configuration, session: self . urlSession)
19
+ self . openAI = OpenAI ( configuration: configuration, session: self . urlSession, streamingSessionFactory : MockStreamingSessionFactory ( ) )
20
20
}
21
21
22
22
func testImages( ) async throws {
@@ -440,21 +440,21 @@ class OpenAITests: XCTestCase {
440
440
441
441
func testDefaultHostURLBuilt( ) {
442
442
let configuration = OpenAI . Configuration ( token: " foo " , organizationIdentifier: " bar " , timeoutInterval: 14 )
443
- let openAI = OpenAI ( configuration: configuration, session: self . urlSession)
443
+ let openAI = OpenAI ( configuration: configuration, session: self . urlSession, streamingSessionFactory : MockStreamingSessionFactory ( ) )
444
444
let chatsURL = openAI. buildURL ( path: . chats)
445
445
XCTAssertEqual ( chatsURL, URL ( string: " https://api.openai.com:443/v1/chat/completions " ) )
446
446
}
447
447
448
448
func testDefaultHostURLBuiltWithCustomBasePath( ) {
449
449
let configuration = OpenAI . Configuration ( token: " foo " , organizationIdentifier: " bar " , basePath: " /api/v9527 " , timeoutInterval: 14 )
450
- let openAI = OpenAI ( configuration: configuration, session: self . urlSession)
450
+ let openAI = OpenAI ( configuration: configuration, session: self . urlSession, streamingSessionFactory : MockStreamingSessionFactory ( ) )
451
451
let chatsURL = openAI. buildURL ( path: . chats)
452
452
XCTAssertEqual ( chatsURL, URL ( string: " https://api.openai.com:443/api/v9527/chat/completions " ) )
453
453
}
454
454
455
455
func testCustomURLBuiltWithPredefinedPath( ) {
456
456
let configuration = OpenAI . Configuration ( token: " foo " , organizationIdentifier: " bar " , host: " my.host.com " , timeoutInterval: 14 )
457
- let openAI = OpenAI ( configuration: configuration, session: self . urlSession)
457
+ let openAI = OpenAI ( configuration: configuration, session: self . urlSession, streamingSessionFactory : MockStreamingSessionFactory ( ) )
458
458
let chatsURL = openAI. buildURL ( path: . chats)
459
459
XCTAssertEqual ( chatsURL, URL ( string: " https://my.host.com:443/v1/chat/completions " ) )
460
460
}
@@ -466,7 +466,7 @@ class OpenAITests: XCTestCase {
466
466
host: " bizbaz.com " ,
467
467
timeoutInterval: 14
468
468
)
469
- let openAI = OpenAI ( configuration: configuration, session: URLSessionMock ( ) )
469
+ let openAI = OpenAI ( configuration: configuration, session: URLSessionMock ( ) , streamingSessionFactory : MockStreamingSessionFactory ( ) )
470
470
XCTAssertEqual ( openAI. buildURL ( path: " foo " ) , URL ( string: " https://bizbaz.com:443/v1/foo " ) )
471
471
}
472
472
@@ -478,7 +478,7 @@ class OpenAITests: XCTestCase {
478
478
basePath: " /openai " ,
479
479
timeoutInterval: 14
480
480
)
481
- let openAI = OpenAI ( configuration: configuration, session: URLSessionMock ( ) )
481
+ let openAI = OpenAI ( configuration: configuration, session: URLSessionMock ( ) , streamingSessionFactory : MockStreamingSessionFactory ( ) )
482
482
XCTAssertEqual ( openAI. buildURL ( path: " foo " ) , URL ( string: " https://bizbaz.com:443/openai/foo " ) )
483
483
}
484
484
@@ -490,7 +490,7 @@ class OpenAITests: XCTestCase {
490
490
basePath: " /openai/ " ,
491
491
timeoutInterval: 14
492
492
)
493
- let openAI = OpenAI ( configuration: configuration, session: URLSessionMock ( ) )
493
+ let openAI = OpenAI ( configuration: configuration, session: URLSessionMock ( ) , streamingSessionFactory : MockStreamingSessionFactory ( ) )
494
494
XCTAssertEqual ( openAI. buildURL ( path: " /foo " ) , URL ( string: " https://bizbaz.com:443/openai/foo " ) )
495
495
}
496
496
@@ -709,21 +709,21 @@ class OpenAITests: XCTestCase {
709
709
710
710
func testCustomRunsURLBuilt( ) {
711
711
let configuration = OpenAI . Configuration ( token: " foo " , organizationIdentifier: " bar " , host: " my.host.com " , timeoutInterval: 14 )
712
- let openAI = OpenAI ( configuration: configuration, session: self . urlSession)
712
+ let openAI = OpenAI ( configuration: configuration, session: self . urlSession, streamingSessionFactory : MockStreamingSessionFactory ( ) )
713
713
let completionsURL = openAI. buildRunsURL ( path: APIPath . Assistants. runs. stringValue, threadId: " thread_4321 " )
714
714
XCTAssertEqual ( completionsURL, URL ( string: " https://my.host.com:443/v1/threads/thread_4321/runs " ) )
715
715
}
716
716
717
717
func testCustomRunsRetrieveURLBuilt( ) {
718
718
let configuration = OpenAI . Configuration ( token: " foo " , organizationIdentifier: " bar " , host: " my.host.com " , timeoutInterval: 14 )
719
- let openAI = OpenAI ( configuration: configuration, session: self . urlSession)
719
+ let openAI = OpenAI ( configuration: configuration, session: self . urlSession, streamingSessionFactory : MockStreamingSessionFactory ( ) )
720
720
let completionsURL = openAI. buildRunRetrieveURL ( path: APIPath . Assistants. runRetrieve. stringValue, threadId: " thread_4321 " , runId: " run_1234 " )
721
721
XCTAssertEqual ( completionsURL, URL ( string: " https://my.host.com:443/v1/threads/thread_4321/runs/run_1234 " ) )
722
722
}
723
723
724
724
func testCustomRunRetrieveStepsURLBuilt( ) {
725
725
let configuration = OpenAI . Configuration ( token: " foo " , organizationIdentifier: " bar " , host: " my.host.com " , timeoutInterval: 14 )
726
- let openAI = OpenAI ( configuration: configuration, session: self . urlSession)
726
+ let openAI = OpenAI ( configuration: configuration, session: self . urlSession, streamingSessionFactory : MockStreamingSessionFactory ( ) )
727
727
let completionsURL = openAI. buildRunRetrieveURL ( path: APIPath . Assistants. runRetrieveSteps. stringValue, threadId: " thread_4321 " , runId: " run_1234 " )
728
728
XCTAssertEqual ( completionsURL, URL ( string: " https://my.host.com:443/v1/threads/thread_4321/runs/run_1234/steps " ) )
729
729
}
0 commit comments