Skip to content

Commit

Permalink
Mock requests to the Models API to fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dkotter committed Jan 9, 2024
1 parent 290f675 commit 3529e01
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tests/test-plugin/e2e-test-plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ function classifai_test_mock_http_requests( $preempt, $parsed_args, $url ) {

if ( strpos( $url, 'http://e2e-test-nlu-server.test/v1/analyze' ) !== false ) {
$response = file_get_contents( __DIR__ . '/nlu.json' );
} elseif ( strpos( $url, 'https://api.openai.com/v1/models' ) !== false ) {
$response = file_get_contents( __DIR__ . '/models.json' );
} elseif ( strpos( $url, 'https://api.openai.com/v1/completions' ) !== false ) {
$response = file_get_contents( __DIR__ . '/chatgpt.json' );
} elseif ( strpos( $url, 'https://api.openai.com/v1/chat/completions' ) !== false ) {
Expand Down
23 changes: 23 additions & 0 deletions tests/test-plugin/models.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"object": "list",
"data": [
{
"id": "model-id-0",
"object": "model",
"created": 1686935002,
"owned_by": "organization-owner"
},
{
"id": "model-id-1",
"object": "model",
"created": 1686935002,
"owned_by": "organization-owner"
},
{
"id": "model-id-2",
"object": "model",
"created": 1686935002,
"owned_by": "openai"
}
]
}

0 comments on commit 3529e01

Please sign in to comment.