summaryrefslogtreecommitdiffstats
path: root/etc/unittest/asyncio.py
diff options
context:
space:
mode:
authorH Lohaus <hlohaus@users.noreply.github.com>2024-02-14 09:22:32 +0100
committerGitHub <noreply@github.com>2024-02-14 09:22:32 +0100
commit51686409f86e187d9c13cbea9388f31f567a118c (patch)
treec4291ff5375b77d70622cfa25490f5a02a5ee970 /etc/unittest/asyncio.py
parentUpdate client.md (diff)
parentAdd unitests for the client (diff)
downloadgpt4free-51686409f86e187d9c13cbea9388f31f567a118c.tar
gpt4free-51686409f86e187d9c13cbea9388f31f567a118c.tar.gz
gpt4free-51686409f86e187d9c13cbea9388f31f567a118c.tar.bz2
gpt4free-51686409f86e187d9c13cbea9388f31f567a118c.tar.lz
gpt4free-51686409f86e187d9c13cbea9388f31f567a118c.tar.xz
gpt4free-51686409f86e187d9c13cbea9388f31f567a118c.tar.zst
gpt4free-51686409f86e187d9c13cbea9388f31f567a118c.zip
Diffstat (limited to '')
-rw-r--r--etc/unittest/asyncio.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/etc/unittest/asyncio.py b/etc/unittest/asyncio.py
index e886c43a..57a1fb7d 100644
--- a/etc/unittest/asyncio.py
+++ b/etc/unittest/asyncio.py
@@ -8,6 +8,7 @@ import unittest
import g4f
from g4f import ChatCompletion
+from g4f.client import Client
from .mocks import ProviderMock, AsyncProviderMock, AsyncGeneratorProviderMock
DEFAULT_MESSAGES = [{'role': 'user', 'content': 'Hello'}]
@@ -24,11 +25,16 @@ class TestChatCompletion(unittest.TestCase):
def test_create(self):
result = ChatCompletion.create(g4f.models.default, DEFAULT_MESSAGES, AsyncProviderMock)
- self.assertEqual("Mock",result)
+ self.assertEqual("Mock", result)
def test_create_generator(self):
result = ChatCompletion.create(g4f.models.default, DEFAULT_MESSAGES, AsyncGeneratorProviderMock)
- self.assertEqual("Mock",result)
+ self.assertEqual("Mock", result)
+
+ def test_await_callback(self):
+ client = Client(provider=AsyncGeneratorProviderMock)
+ response = client.chat.completions.create(DEFAULT_MESSAGES, "", max_tokens=0)
+ self.assertEqual("Mock", response.choices[0].message.content)
class TestChatCompletionAsync(unittest.IsolatedAsyncioTestCase):