diff options
author | Heiner Lohaus <hlohaus@users.noreply.github.com> | 2024-02-22 00:16:58 +0100 |
---|---|---|
committer | Heiner Lohaus <hlohaus@users.noreply.github.com> | 2024-02-22 00:16:58 +0100 |
commit | e5b7f72b719814ffa2748e8e8ed1c6713a24e1a6 (patch) | |
tree | 70e9f87cb18f165428492d53a1c6e28c0828490a /etc | |
parent | Update docs / readme, Improve Gemini auth (diff) | |
download | gpt4free-e5b7f72b719814ffa2748e8e8ed1c6713a24e1a6.tar gpt4free-e5b7f72b719814ffa2748e8e8ed1c6713a24e1a6.tar.gz gpt4free-e5b7f72b719814ffa2748e8e8ed1c6713a24e1a6.tar.bz2 gpt4free-e5b7f72b719814ffa2748e8e8ed1c6713a24e1a6.tar.lz gpt4free-e5b7f72b719814ffa2748e8e8ed1c6713a24e1a6.tar.xz gpt4free-e5b7f72b719814ffa2748e8e8ed1c6713a24e1a6.tar.zst gpt4free-e5b7f72b719814ffa2748e8e8ed1c6713a24e1a6.zip |
Diffstat (limited to 'etc')
-rw-r--r-- | etc/tool/readme_table.py | 2 | ||||
-rw-r--r-- | etc/unittest/__main__.py | 2 | ||||
-rw-r--r-- | etc/unittest/backend.py | 14 | ||||
-rw-r--r-- | etc/unittest/client.py | 2 | ||||
-rw-r--r-- | etc/unittest/include.py | 18 | ||||
-rw-r--r-- | etc/unittest/mocks.py | 2 |
6 files changed, 26 insertions, 14 deletions
diff --git a/etc/tool/readme_table.py b/etc/tool/readme_table.py index d5a409ec..293d1eb3 100644 --- a/etc/tool/readme_table.py +++ b/etc/tool/readme_table.py @@ -3,7 +3,7 @@ from urllib.parse import urlparse import asyncio from g4f import models, ChatCompletion -from g4f.base_provider import BaseProvider, BaseRetryProvider, ProviderType +from g4f.providers.types import BaseRetryProvider, ProviderType from etc.testing._providers import get_providers from g4f import debug diff --git a/etc/unittest/__main__.py b/etc/unittest/__main__.py index a133343e..06b2dff5 100644 --- a/etc/unittest/__main__.py +++ b/etc/unittest/__main__.py @@ -3,5 +3,7 @@ from .asyncio import * from .backend import * from .main import * from .model import * +from .client import * +from .include import * unittest.main()
\ No newline at end of file diff --git a/etc/unittest/backend.py b/etc/unittest/backend.py index e4a7b3ab..846c3554 100644 --- a/etc/unittest/backend.py +++ b/etc/unittest/backend.py @@ -1,9 +1,11 @@ import unittest +# import asyncio from unittest.mock import MagicMock from .mocks import ProviderMock import g4f try: from g4f.gui.server.backend import Backend_Api, get_error_message + # from g4f.gui.server.internet import search has_requirements = True except: has_requirements = False @@ -16,10 +18,10 @@ class TestBackendApi(unittest.TestCase): self.app = MagicMock() self.api = Backend_Api(self.app) - def test_version(self): - response = self.api.get_version() - self.assertIn("version", response) - self.assertIn("latest_version", response) + # def test_version(self): + # response = self.api.get_version() + # self.assertIn("version", response) + # self.assertIn("latest_version", response) def test_get_models(self): response = self.api.get_models() @@ -31,6 +33,10 @@ class TestBackendApi(unittest.TestCase): self.assertIsInstance(response, list) self.assertTrue(len(response) > 0) + # def test_search(self): + # result = asyncio.run(search("Hello")) + # self.assertEqual(5, len(result)) + class TestUtilityFunctions(unittest.TestCase): def setUp(self): diff --git a/etc/unittest/client.py b/etc/unittest/client.py index c63edbd2..2bc00c2e 100644 --- a/etc/unittest/client.py +++ b/etc/unittest/client.py @@ -43,7 +43,7 @@ class TestPassModel(unittest.TestCase): for chunk in response: self.assertEqual(chunk.choices[0].delta.content, "You ") - def no_test_stop(self): + def test_stop(self): client = Client(provider=YieldProviderMock) messages = [{'role': 'user', 'content': chunk} for chunk in ["How ", "are ", "you", "?"]] response = client.chat.completions.create(messages, "Hello", stop=["and"]) diff --git a/etc/unittest/include.py b/etc/unittest/include.py index e67fd5a7..9695bc5b 100644 --- a/etc/unittest/include.py +++ b/etc/unittest/include.py @@ -1,11 +1,15 @@ -import sys -import pathlib +import unittest -sys.path.append(str(pathlib.Path(__file__).parent.parent.parent)) +class TestImport(unittest.TestCase): -import g4f + def test_get_cookies(self): + from g4f import get_cookies as get_cookies_alias + from g4f.cookies import get_cookies + self.assertEqual(get_cookies_alias, get_cookies) -g4f.debug.logging = False -g4f.debug.version_check = False + def test_requests(self): + from g4f.requests import StreamSession + self.assertIsInstance(StreamSession, type) -DEFAULT_MESSAGES = [{'role': 'user', 'content': 'Hello'}]
\ No newline at end of file +if __name__ == '__main__': + unittest.main()
\ No newline at end of file diff --git a/etc/unittest/mocks.py b/etc/unittest/mocks.py index 8a67aaf7..102730fa 100644 --- a/etc/unittest/mocks.py +++ b/etc/unittest/mocks.py @@ -1,4 +1,4 @@ -from g4f.Provider.base_provider import AbstractProvider, AsyncProvider, AsyncGeneratorProvider +from g4f.providers.base_provider import AbstractProvider, AsyncProvider, AsyncGeneratorProvider class ProviderMock(AbstractProvider): working = True |