33 lines
1.0 KiB
Python
33 lines
1.0 KiB
Python
from kazeia_central.adb import parse_content_query
|
|
from kazeia_central.adb.client import parse_call_bundle
|
|
from kazeia_central.provider import models as m
|
|
|
|
|
|
def test_parse_rows():
|
|
out = (
|
|
"Row: 0 pid=1234, uptime_seconds=42, pss_mb=512, ion_mb=300, "
|
|
"anon_pages_mb=100, mem_available_mb=2048\n"
|
|
)
|
|
rows = parse_content_query(out)
|
|
assert len(rows) == 1
|
|
st = m.StateRow(**rows[0])
|
|
assert st.pid == 1234
|
|
assert st.mem_available_mb == 2048
|
|
|
|
|
|
def test_parse_null_and_empty():
|
|
assert parse_content_query("No result found.") == []
|
|
rows = parse_content_query("Row: 0 component=stt, message=NULL")
|
|
assert rows[0]["message"] is None
|
|
|
|
|
|
def test_bool_coercion():
|
|
rows = parse_content_query("Row: 0 enabled=1, ready=0, model=e5-small, dim=384")
|
|
rs = m.RagStatus(**rows[0])
|
|
assert rs.enabled is True and rs.ready is False and rs.dim == 384
|
|
|
|
|
|
def test_call_bundle():
|
|
b = parse_call_bundle("Result: Bundle[{ok=true, count=3}]")
|
|
assert b["ok"] == "true" and b["count"] == "3"
|