summaryrefslogtreecommitdiffstats
path: root/etc
diff options
context:
space:
mode:
Diffstat (limited to 'etc')
-rw-r--r--etc/tool/readme_table.py2
-rw-r--r--etc/unittest/__main__.py2
-rw-r--r--etc/unittest/backend.py14
-rw-r--r--etc/unittest/client.py2
-rw-r--r--etc/unittest/include.py18
-rw-r--r--etc/unittest/mocks.py2
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