wartung: Groesse je Quantisierung, GitHub-Antworten 15 min gemerkt, Hermes-Version auch bei haengendem Abruf
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
0e961f112b
commit
ee2bb9d03c
@@ -0,0 +1,63 @@
|
||||
"""Kleinigkeiten der Update-Seite (24.09.2026): Größe je Quantisierung, GitHub-Zwischenspeicher,
|
||||
Hermes-Version auch dann, wenn der Abruf scheitert."""
|
||||
|
||||
import subprocess
|
||||
|
||||
import httpx
|
||||
import pytest
|
||||
from services import hf, maintenance
|
||||
|
||||
|
||||
def test_quants_mit_groesse(monkeypatch):
|
||||
baum = [
|
||||
{"path": "Q8_0/M-Q8_0-00001-of-00002.gguf", "size": 50},
|
||||
{"path": "Q8_0/M-Q8_0-00002-of-00002.gguf", "size": 50},
|
||||
{"path": "M-Q4_K_M.gguf", "lfs": {"size": 30}},
|
||||
{"path": "mmproj-F16.gguf", "size": 5},
|
||||
{"path": "README.md", "size": 1},
|
||||
]
|
||||
aufrufe = []
|
||||
monkeypatch.setattr(hf, "_tree", lambda repo: aufrufe.append(repo) or baum)
|
||||
assert hf.list_quants("x/y") == [{"quant": "Q4_K_M", "total_bytes": 35}, {"quant": "Q8_0", "total_bytes": 105}]
|
||||
assert aufrufe == ["x/y"] # ein Abruf für alle Stufen
|
||||
|
||||
|
||||
class _Antwort:
|
||||
def __init__(self, status: int, daten: object):
|
||||
self.status_code = status
|
||||
self._daten = daten
|
||||
|
||||
def raise_for_status(self):
|
||||
if self.status_code >= 400:
|
||||
raise httpx.HTTPStatusError("fehler", request=httpx.Request("GET", "https://x"),
|
||||
response=httpx.Response(self.status_code))
|
||||
|
||||
def json(self):
|
||||
return self._daten
|
||||
|
||||
|
||||
def test_github_antworten_werden_gemerkt_fehler_nicht(monkeypatch):
|
||||
monkeypatch.setattr(maintenance, "_github_cache", {})
|
||||
antworten = [_Antwort(403, {"message": "API rate limit exceeded"}), _Antwort(200, {"tag_name": "v258"})]
|
||||
aufrufe = []
|
||||
monkeypatch.setattr(maintenance.httpx, "get", lambda url, **kw: aufrufe.append(url) or antworten.pop(0))
|
||||
with pytest.raises(httpx.HTTPStatusError):
|
||||
maintenance._github_json("repos/a/b/releases/latest")
|
||||
assert maintenance._github_json("repos/a/b/releases/latest") == {"tag_name": "v258"}
|
||||
assert maintenance._github_json("repos/a/b/releases/latest") == {"tag_name": "v258"}
|
||||
assert len(aufrufe) == 2
|
||||
|
||||
|
||||
def test_hermes_version_auch_wenn_der_abruf_haengt(monkeypatch, tmp_path):
|
||||
(tmp_path / "pyproject.toml").write_text('[project]\nversion = "0.21.4"\n', encoding="utf-8")
|
||||
monkeypatch.setattr(maintenance.system, "find_hermes_agent_git", lambda: {"path": str(tmp_path)})
|
||||
|
||||
def run(befehl, **kw):
|
||||
if "fetch" in befehl:
|
||||
raise subprocess.TimeoutExpired(befehl, 25)
|
||||
return subprocess.CompletedProcess(befehl, 0, stdout="main\n", stderr="")
|
||||
|
||||
monkeypatch.setattr(maintenance.subprocess, "run", run)
|
||||
info = maintenance.hermes_update_details()
|
||||
assert info["installed_version"] == "0.21.4"
|
||||
assert "error" in info
|
||||
Reference in New Issue
Block a user