summaryrefslogtreecommitdiffstats
path: root/etc/unittest/asyncio.py
diff options
context:
space:
mode:
authorHeiner Lohaus <hlohaus@users.noreply.github.com>2024-02-14 09:21:57 +0100
committerHeiner Lohaus <hlohaus@users.noreply.github.com>2024-02-14 09:21:57 +0100
commite1a0b3ffa2aa6e5a7c068cdc559ca126f3b57b4c (patch)
treed8f146187920ffc683953a1e4f0c8476867b7ef4 /etc/unittest/asyncio.py
parentAdd variant example (diff)
downloadgpt4free-e1a0b3ffa2aa6e5a7c068cdc559ca126f3b57b4c.tar
gpt4free-e1a0b3ffa2aa6e5a7c068cdc559ca126f3b57b4c.tar.gz
gpt4free-e1a0b3ffa2aa6e5a7c068cdc559ca126f3b57b4c.tar.bz2
gpt4free-e1a0b3ffa2aa6e5a7c068cdc559ca126f3b57b4c.tar.lz
gpt4free-e1a0b3ffa2aa6e5a7c068cdc559ca126f3b57b4c.tar.xz
gpt4free-e1a0b3ffa2aa6e5a7c068cdc559ca126f3b57b4c.tar.zst
gpt4free-e1a0b3ffa2aa6e5a7c068cdc559ca126f3b57b4c.zip
Diffstat (limited to 'etc/unittest/asyncio.py')
-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):