29 lines
834 B
Python
29 lines
834 B
Python
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()
|