From 770bdc54fc52a71ff56ec0e7f1a38adba01f0ae0 Mon Sep 17 00:00:00 2001 From: Heiner Lohaus Date: Mon, 29 Jan 2024 20:13:54 +0100 Subject: Improve readme / unittests --- etc/unittest/main.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'etc/unittest/main.py') diff --git a/etc/unittest/main.py b/etc/unittest/main.py index f5eb5138..cc3c6a18 100644 --- a/etc/unittest/main.py +++ b/etc/unittest/main.py @@ -24,12 +24,19 @@ class TestGetLastProvider(unittest.TestCase): def test_get_last_provider(self): ChatCompletion.create(g4f.models.default, DEFAULT_MESSAGES, ProviderMock) self.assertEqual(get_last_provider(), ProviderMock) - + def test_get_last_provider_retry(self): ChatCompletion.create(g4f.models.default, DEFAULT_MESSAGES, RetryProvider([ProviderMock])) self.assertEqual(get_last_provider(), ProviderMock) - + def test_get_last_provider_async(self): coroutine = ChatCompletion.create_async(g4f.models.default, DEFAULT_MESSAGES, ProviderMock) asyncio.run(coroutine) - self.assertEqual(get_last_provider(), ProviderMock) \ No newline at end of file + self.assertEqual(get_last_provider(), ProviderMock) + + def test_get_last_provider_as_dict(self): + ChatCompletion.create(g4f.models.default, DEFAULT_MESSAGES, ProviderMock) + last_provider_dict = get_last_provider(True) + self.assertIsInstance(last_provider_dict, dict) + self.assertIn('name', last_provider_dict) + self.assertEqual(ProviderMock.__name__, last_provider_dict['name']) \ No newline at end of file -- cgit v1.2.3