-
-
Notifications
You must be signed in to change notification settings - Fork 523
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0575905
commit bc40271
Showing
12 changed files
with
402 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
src/Testing/Responses/Fixtures/Assistants/AssistantDeleteResponseFixture.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
|
||
namespace OpenAI\Testing\Responses\Fixtures\Assistants; | ||
|
||
final class AssistantDeleteResponseFixture | ||
{ | ||
public const ATTRIBUTES = [ | ||
'id' => 'asst_SMzoVX8XmCZEg1EbMHoAm8tc', | ||
'object' => 'assistant.deleted', | ||
'deleted' => true, | ||
]; | ||
} |
27 changes: 27 additions & 0 deletions
27
src/Testing/Responses/Fixtures/Assistants/AssistantListResponseFixture.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
namespace OpenAI\Testing\Responses\Fixtures\Assistants; | ||
|
||
final class AssistantListResponseFixture | ||
{ | ||
public const ATTRIBUTES = [ | ||
'object' => 'list', | ||
'data' => [ | ||
[ | ||
'id' => 'asst_SMzoVX8XmCZEg1EbMHoAm8tc', | ||
'object' => 'assistant', | ||
'created_at' => 1_699_619_403, | ||
'name' => 'Math Tutor', | ||
'description' => null, | ||
'model' => 'gpt-4', | ||
'instructions' => 'You are a personal math tutor.', | ||
'tools' => [], | ||
'file_ids' => [], | ||
'metadata' => [], | ||
], | ||
], | ||
'first_id' => 'asst_SMzoVX8XmCZEg1EbMHoAm8tc', | ||
'last_id' => 'asst_SMzoVX8XmCZEg1EbMHoAm8tc', | ||
'has_more' => false, | ||
]; | ||
} |
19 changes: 19 additions & 0 deletions
19
src/Testing/Responses/Fixtures/Assistants/AssistantResponseFixture.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace OpenAI\Testing\Responses\Fixtures\Assistants; | ||
|
||
final class AssistantResponseFixture | ||
{ | ||
public const ATTRIBUTES = [ | ||
'id' => 'asst_SMzoVX8XmCZEg1EbMHoAm8tc', | ||
'object' => 'assistant', | ||
'created_at' => 1_699_619_403, | ||
'name' => 'Math Tutor', | ||
'description' => null, | ||
'model' => 'gpt-4', | ||
'instructions' => 'You are a personal math tutor.', | ||
'tools' => [], | ||
'file_ids' => [], | ||
'metadata' => [], | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
use OpenAI\Responses\Assistants\AssistantDeleteResponse; | ||
use OpenAI\Responses\Meta\MetaInformation; | ||
|
||
test('from', function () { | ||
$result = AssistantDeleteResponse::from(assistantDeleteResource(), meta()); | ||
|
||
expect($result) | ||
->id->toBe('asst_SMzoVX8XmCZEg1EbMHoAm8tc') | ||
->object->toBe('assistant.deleted') | ||
->deleted->toBe(true) | ||
->meta()->toBeInstanceOf(MetaInformation::class); | ||
}); | ||
|
||
test('as array accessible', function () { | ||
$result = AssistantDeleteResponse::from(assistantDeleteResource(), meta()); | ||
|
||
expect($result['id']) | ||
->toBe('asst_SMzoVX8XmCZEg1EbMHoAm8tc'); | ||
}); | ||
|
||
test('to array', function () { | ||
$result = AssistantDeleteResponse::from(assistantDeleteResource(), meta()); | ||
|
||
expect($result->toArray()) | ||
->toBe(assistantDeleteResource()); | ||
}); | ||
|
||
test('fake', function () { | ||
$response = AssistantDeleteResponse::fake(); | ||
|
||
expect($response) | ||
->id->toBe('asst_SMzoVX8XmCZEg1EbMHoAm8tc') | ||
->deleted->toBe(true); | ||
}); | ||
|
||
test('fake with override', function () { | ||
$response = AssistantDeleteResponse::fake([ | ||
'id' => 'asst_1234', | ||
'deleted' => false, | ||
]); | ||
|
||
expect($response) | ||
->id->toBe('asst_1234') | ||
->deleted->toBe(false); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
use OpenAI\Responses\Assistants\AssistantListResponse; | ||
use OpenAI\Responses\Assistants\AssistantResponse; | ||
use OpenAI\Responses\Meta\MetaInformation; | ||
|
||
test('from', function () { | ||
$response = AssistantListResponse::from(assistantListResource(), meta()); | ||
|
||
expect($response) | ||
->toBeInstanceOf(AssistantListResponse::class) | ||
->object->toBe('list') | ||
->data->toBeArray()->toHaveCount(2) | ||
->data->each->toBeInstanceOf(AssistantResponse::class) | ||
->meta()->toBeInstanceOf(MetaInformation::class); | ||
}); | ||
|
||
test('as array accessible', function () { | ||
$response = AssistantListResponse::from(assistantListResource(), meta()); | ||
|
||
expect($response['object'])->toBe('list'); | ||
}); | ||
|
||
test('to array', function () { | ||
$response = AssistantListResponse::from(assistantListResource(), meta()); | ||
|
||
expect($response->toArray()) | ||
->toBeArray() | ||
->toBe(assistantListResource()); | ||
}); | ||
|
||
test('fake', function () { | ||
$response = AssistantListResponse::fake(); | ||
|
||
expect($response['data'][0]) | ||
->id->toBe('asst_SMzoVX8XmCZEg1EbMHoAm8tc'); | ||
}); | ||
|
||
test('fake with override', function () { | ||
$response = AssistantListResponse::fake([ | ||
'data' => [ | ||
[ | ||
'id' => 'asst_1234', | ||
], | ||
], | ||
]); | ||
|
||
expect($response['data'][0]) | ||
->id->toBe('asst_1234'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
use OpenAI\Responses\Assistants\AssistantResponse; | ||
use OpenAI\Responses\Assistants\AssistantResponseToolCodeInterpreter; | ||
use OpenAI\Responses\Meta\MetaInformation; | ||
|
||
test('from', function () { | ||
$result = AssistantResponse::from(assistantWithAllToolsResource(), meta()); | ||
|
||
expect($result) | ||
->id->toBe('asst_SMzoVX8XmCZEg1EbMHoAm8tc') | ||
->object->toBe('assistant') | ||
->createdAt->toBe(1699619403) | ||
->name->toBe('Math Tutor') | ||
->description->toBeNull() | ||
->model->toBe('gpt-4') | ||
->instructions->toBe('You are a personal math tutor.') | ||
->tools->toBeArray() | ||
->tools->{0}->toBeInstanceOf(AssistantResponseToolCodeInterpreter::class) | ||
->fileIds->toBeArray() | ||
->metadata->toBeArray() | ||
->meta()->toBeInstanceOf(MetaInformation::class); | ||
}); | ||
|
||
test('to array', function () { | ||
$result = AssistantResponse::from(assistantWithAllToolsResource(), meta()); | ||
|
||
expect($result->toArray()) | ||
->toBe(assistantWithAllToolsResource()); | ||
}); | ||
|
||
test('fake', function () { | ||
$response = AssistantResponse::fake(); | ||
|
||
expect($response) | ||
->id->toBe('asst_SMzoVX8XmCZEg1EbMHoAm8tc'); | ||
}); | ||
|
||
test('fake with override', function () { | ||
$response = AssistantResponse::fake([ | ||
'id' => 'asst_1234', | ||
]); | ||
|
||
expect($response) | ||
->id->toBe('asst_1234'); | ||
}); |
17 changes: 17 additions & 0 deletions
17
tests/Responses/Assistants/AssistantResponseToolCodeInterpreter.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
use OpenAI\Responses\Assistants\AssistantResponseToolCodeInterpreter; | ||
|
||
test('from', function () { | ||
$result = AssistantResponseToolCodeInterpreter::from(assistantResource()['tools'][0]); | ||
|
||
expect($result) | ||
->type->toBe('code_interpreter'); | ||
}); | ||
|
||
test('to array', function () { | ||
$result = AssistantResponseToolCodeInterpreter::from(assistantResource()['tools'][0]); | ||
|
||
expect($result->toArray()) | ||
->toBe(assistantResource()['tools'][0]); | ||
}); |
19 changes: 19 additions & 0 deletions
19
tests/Responses/Assistants/AssistantResponseToolFunction.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
use OpenAI\Responses\Assistants\AssistantResponseToolFunction; | ||
use OpenAI\Responses\Assistants\AssistantResponseToolFunctionFunction; | ||
|
||
test('from', function () { | ||
$result = AssistantResponseToolFunction::from(assistantWithFunctionToolResource()['tools'][0]); | ||
|
||
expect($result) | ||
->type->toBe('function') | ||
->function->toBeInstanceOf(AssistantResponseToolFunctionFunction::class); | ||
}); | ||
|
||
test('to array', function () { | ||
$result = AssistantResponseToolFunction::from(assistantWithFunctionToolResource()['tools'][0]); | ||
|
||
expect($result->toArray()) | ||
->toBe(assistantWithFunctionToolResource()['tools'][0]); | ||
}); |
Oops, something went wrong.