diff options
author | Heiner Lohaus <hlohaus@users.noreply.github.com> | 2024-02-22 04:35:11 +0100 |
---|---|---|
committer | Heiner Lohaus <hlohaus@users.noreply.github.com> | 2024-02-22 04:35:11 +0100 |
commit | 1b4a86a857d9f9b77e0c7f0cd87468b627a250c8 (patch) | |
tree | f8a7102b0c633c6460a2e5fd9326434e18dfc9c6 /etc/unittest/backend.py | |
parent | Move some modules, create providers dir (diff) | |
download | gpt4free-1b4a86a857d9f9b77e0c7f0cd87468b627a250c8.tar gpt4free-1b4a86a857d9f9b77e0c7f0cd87468b627a250c8.tar.gz gpt4free-1b4a86a857d9f9b77e0c7f0cd87468b627a250c8.tar.bz2 gpt4free-1b4a86a857d9f9b77e0c7f0cd87468b627a250c8.tar.lz gpt4free-1b4a86a857d9f9b77e0c7f0cd87468b627a250c8.tar.xz gpt4free-1b4a86a857d9f9b77e0c7f0cd87468b627a250c8.tar.zst gpt4free-1b4a86a857d9f9b77e0c7f0cd87468b627a250c8.zip |
Diffstat (limited to '')
-rw-r--r-- | etc/unittest/backend.py | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/etc/unittest/backend.py b/etc/unittest/backend.py index 846c3554..c4ab219e 100644 --- a/etc/unittest/backend.py +++ b/etc/unittest/backend.py @@ -1,15 +1,15 @@ import unittest -# import asyncio +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 - + class TestBackendApi(unittest.TestCase): def setUp(self): @@ -18,25 +18,27 @@ 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() 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): - # result = asyncio.run(search("Hello")) - # self.assertEqual(5, len(result)) - + + 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): @@ -48,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 |