Added local Ollama model listing in the U
This commit is contained in:
28
tests/test_dashboard.py
Normal file
28
tests/test_dashboard.py
Normal file
@@ -0,0 +1,28 @@
|
||||
import json
|
||||
import unittest
|
||||
from unittest.mock import patch
|
||||
|
||||
from fgai.dashboard import _ollama_models
|
||||
|
||||
|
||||
class DashboardTests(unittest.TestCase):
|
||||
def test_ollama_models_returns_sorted_model_names(self):
|
||||
class Response:
|
||||
def __enter__(self):
|
||||
return self
|
||||
|
||||
def __exit__(self, *_args):
|
||||
return False
|
||||
|
||||
def read(self):
|
||||
return json.dumps({"models": [{"name": "qwen3:8b", "size": 2}, {"name": "llama3.1", "size": 1}]}).encode("utf-8")
|
||||
|
||||
with patch("fgai.dashboard.request.urlopen", return_value=Response()):
|
||||
result = _ollama_models()
|
||||
|
||||
self.assertEqual(result["status"], "ok")
|
||||
self.assertEqual([item["name"] for item in result["models"]], ["llama3.1", "qwen3:8b"])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user