Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
Signed-off-by: Julien Veyssier <[email protected]>
  • Loading branch information
julien-nc committed Jun 15, 2024
1 parent 49c5b5d commit b75ed86
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,4 @@ jobs:
- name: PHPUnit
working-directory: apps/${{ env.APP_NAME }}
run: phpunit -c tests/phpunit.xml
run: composer run text:unit
2 changes: 1 addition & 1 deletion tests/phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ SPDX-License-Identifier: AGPL-3.0-or-later
<clover outputFile="./clover.xml"/>
</report>
</coverage>
<testsuite name="GptFreePrompt App Tests">
<testsuite name="OpenAI integration App Tests">
<directory suffix="Test.php">.</directory>
</testsuite>
<!-- filters for code coverage -->
Expand Down
14 changes: 7 additions & 7 deletions tests/unit/Providers/OpenAiProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
use OCP\Http\Client\IClient;
use OCP\Http\Client\IClientService;
use OCP\IConfig;
use OCP\IL10N;
use PHPUnit\Framework\MockObject\MockObject;
use Test\TestCase;
use Test\Util\User\Dummy;

/**
* @group DB
Expand All @@ -45,7 +45,7 @@ class OpenAiProviderTest extends TestCase {

public static function setUpBeforeClass(): void {
parent::setUpBeforeClass();
$backend = new \Test\Util\User\Dummy();
$backend = new Dummy();
$backend->createUser(self::TEST_USER1, self::TEST_USER1);
\OC::$server->get(\OCP\IUserManager::class)->registerBackend($backend);
}
Expand Down Expand Up @@ -97,7 +97,7 @@ public function testFreePromptProvider(): void {
$this->openAiApiService,
\OC::$server->get(IConfig::class),
$this->openAiSettingsService,
\OC::$server->get(IL10N::class),
$this->createMock(\OCP\IL10N::class),
self::TEST_USER1,
);

Expand Down Expand Up @@ -153,7 +153,7 @@ public function testHeadlineProvider(): void {
$this->openAiApiService,
\OC::$server->get(IConfig::class),
$this->openAiSettingsService,
\OC::$server->get(IL10N::class),
$this->createMock(\OCP\IL10N::class),
self::TEST_USER1,
);

Expand Down Expand Up @@ -186,7 +186,7 @@ public function testHeadlineProvider(): void {
$url = self::OPENAI_API_BASE . 'chat/completions';

$options = ['timeout' => Application::OPENAI_DEFAULT_REQUEST_TIMEOUT, 'headers' => ['User-Agent' => Application::USER_AGENT, 'Authorization' => self::AUTHORIZATION_HEADER, 'Content-Type' => 'application/json']];
$options['body'] = json_encode(['model' => Application::DEFAULT_COMPLETION_MODEL_ID, 'messages' => [['role' => 'user', 'content' => 'Give me the headline of the following text:' . "\n\n" . $prompt]], 'max_tokens' => Application::DEFAULT_MAX_NUM_OF_TOKENS, 'n' => $n, 'user' => self::TEST_USER1]);
$options['body'] = json_encode(['model' => Application::DEFAULT_COMPLETION_MODEL_ID, 'messages' => [['role' => 'user', 'content' => 'Give me the headline of the following text in its original language:' . "\n\n" . $prompt]], 'max_tokens' => Application::DEFAULT_MAX_NUM_OF_TOKENS, 'n' => $n, 'user' => self::TEST_USER1]);

$iResponse = $this->createMock(\OCP\Http\Client\IResponse::class);
$iResponse->method('getBody')->willReturn($response);
Expand All @@ -209,7 +209,7 @@ public function testSummaryProvider(): void {
$this->openAiApiService,
\OC::$server->get(IConfig::class),
$this->openAiSettingsService,
\OC::$server->get(IL10N::class),
$this->createMock(\OCP\IL10N::class),
self::TEST_USER1,
);

Expand Down Expand Up @@ -242,7 +242,7 @@ public function testSummaryProvider(): void {
$url = self::OPENAI_API_BASE . 'chat/completions';

$options = ['timeout' => Application::OPENAI_DEFAULT_REQUEST_TIMEOUT, 'headers' => ['User-Agent' => Application::USER_AGENT, 'Authorization' => self::AUTHORIZATION_HEADER, 'Content-Type' => 'application/json']];
$options['body'] = json_encode(['model' => Application::DEFAULT_COMPLETION_MODEL_ID, 'messages' => [['role' => 'user', 'content' => 'Summarize the following text:' . "\n\n" . $prompt]], 'max_tokens' => Application::DEFAULT_MAX_NUM_OF_TOKENS, 'n' => $n, 'user' => self::TEST_USER1]);
$options['body'] = json_encode(['model' => Application::DEFAULT_COMPLETION_MODEL_ID, 'messages' => [['role' => 'user', 'content' => 'Summarize the following text in its original language:' . "\n\n" . $prompt]], 'max_tokens' => Application::DEFAULT_MAX_NUM_OF_TOKENS, 'n' => $n, 'user' => self::TEST_USER1]);

$iResponse = $this->createMock(\OCP\Http\Client\IResponse::class);
$iResponse->method('getBody')->willReturn($response);
Expand Down

0 comments on commit b75ed86

Please sign in to comment.