openai-php / client

⚡️ OpenAI PHP is a supercharged community-maintained PHP API client that allows you to interact with OpenAI API.
MIT License
4.57k stars 466 forks source link

Add test resources for Assistants and Threads #279

Closed elodieirdor closed 7 months ago

elodieirdor commented 7 months ago

What:

Description:

This PR adds test resources for Assistants and Threads.

Related:

gehrisandro commented 7 months ago

Thank you @elodieirdor

I missed them completely 🙈

elodieirdor commented 7 months ago

Thanks for the merged! Happy to contribute to this great package!! Just realized I broke the tests. Sorry about that! Happy to do a PR with a fix.

Would that be ok if I update OpenAI\Testing\Resources\Concerns\Testable.php with the following

    protected function record(string $method, ...$parameters): ResponseContract|StreamResponse|string
    {
        return $this->fake->record(new TestRequest($this->resource(), $method, $parameters));
    }

Or, I can update each new resource class and send an array ['paramName' => value] to record Example for create in OpenAI\Testing\Resources\AssistantsFilesTestResource

    public function create(string $assistantId, array $parameters): AssistantFileResponse
    {
        return $this->record(__FUNCTION__, ['assistantId' => $assistantId, 'parameters' => $parameters]);
    }
gehrisandro commented 7 months ago

No problem.

I am already working on this one. I've done basically what you have suggested now. Additionally I am going to add the missing tests for the test resources.

elodieirdor commented 7 months ago

Awesome ❤️ . Thank you!

gehrisandro commented 7 months ago

Here is my commit: https://github.com/openai-php/client/commit/da395239f6df941ac17261c054ed5d784890af34

I will tag a new release tomorrow.

elodieirdor commented 7 months ago

Great!! Thanks.