diff options
author | H Lohaus <hlohaus@users.noreply.github.com> | 2024-02-23 03:08:30 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-23 03:08:30 +0100 |
commit | cf87d467c927d4b93916a42e7139f4e801172d62 (patch) | |
tree | 175b39f8486ce72be00a40cc345834abe859c84c /etc/unittest/backend.py | |
parent | ~ (diff) | |
parent | Fix unittests, use Union typing (diff) | |
download | gpt4free-cf87d467c927d4b93916a42e7139f4e801172d62.tar gpt4free-cf87d467c927d4b93916a42e7139f4e801172d62.tar.gz gpt4free-cf87d467c927d4b93916a42e7139f4e801172d62.tar.bz2 gpt4free-cf87d467c927d4b93916a42e7139f4e801172d62.tar.lz gpt4free-cf87d467c927d4b93916a42e7139f4e801172d62.tar.xz gpt4free-cf87d467c927d4b93916a42e7139f4e801172d62.tar.zst gpt4free-cf87d467c927d4b93916a42e7139f4e801172d62.zip |
Diffstat (limited to 'etc/unittest/backend.py')
-rw-r--r-- | etc/unittest/backend.py | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/etc/unittest/backend.py b/etc/unittest/backend.py index e4a7b3ab..c4ab219e 100644 --- a/etc/unittest/backend.py +++ b/etc/unittest/backend.py @@ -1,13 +1,15 @@ 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 has_requirements = True except: has_requirements = False - + class TestBackendApi(unittest.TestCase): def setUp(self): @@ -20,17 +22,23 @@ class TestBackendApi(unittest.TestCase): response = self.api.get_version() self.assertIn("version", response) self.assertIn("latest_version", response) - + def test_get_models(self): response = self.api.get_models() self.assertIsInstance(response, list) self.assertTrue(len(response) > 0) - + def test_get_providers(self): response = self.api.get_providers() self.assertIsInstance(response, list) self.assertTrue(len(response) > 0) - + + def test_search(self): + # Task was destroyed but it is pending! + from g4f.gui.server.internet import search + result = asyncio.run(search("Hello")) + self.assertEqual(5, len(result)) + class TestUtilityFunctions(unittest.TestCase): def setUp(self): @@ -42,6 +50,6 @@ class TestUtilityFunctions(unittest.TestCase): exception = Exception("Message") result = get_error_message(exception) self.assertEqual("ProviderMock: Exception: Message", result) - + if __name__ == '__main__': unittest.main()
\ No newline at end of file |