diff options
Diffstat (limited to 'tests/test_llm.py')
| -rw-r--r-- | tests/test_llm.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/test_llm.py b/tests/test_llm.py new file mode 100644 index 0000000..759666c --- /dev/null +++ b/tests/test_llm.py @@ -0,0 +1,32 @@ +import sys +from pathlib import Path + +sys.path.insert(0, str(Path(__file__).resolve().parent.parent)) + +import unittest + +import deckit.modules.llm as llm + + +class Down(unittest.TestCase): + def test_offline_when_dashboard_down(self): + def boom(url, timeout=2): + raise OSError("refused") + st = llm.make({"llm": {"url": "http://x"}, "fetch": boom}).state() + self.assertTrue(st["offline"]) + + +class Up(unittest.TestCase): + def test_merges_endpoints(self): + data = {"/api/claude_limits": [{"context_pct": 12}], + "/api/claude_session": {"context_used": 1200}, + "/api/summary": {"total_cost": 1.5}} + st = llm.make({"llm": {"url": "http://x"}, + "fetch": lambda u, timeout=2: data[u]}).state() + self.assertFalse(st["offline"]) + self.assertEqual(st["claude"]["context_pct"], 12) + self.assertEqual(st["opencode"]["total_cost"], 1.5) + + +if __name__ == "__main__": + unittest.main() |
