mirror of
https://github.com/dredx/prole.git
synced 2026-09-24 16:44:33 +00:00
- Add build-context helper to copy Docker context safely (ignore runtime data, keep symlinks) - Update UI and core actions to use ~/.prole/build and shared copy helper - Add/adjust tests and scripts; introduce knoe ops helpers and update manifests Co-authored-by: Junie <junie@jetbrains.com>
49 lines
1.4 KiB
Python
49 lines
1.4 KiB
Python
"""Tests for `knoe.core.ollama_scan` parsing helpers."""
|
|
|
|
from __future__ import annotations
|
|
|
|
|
|
from knoe.core.ollama_scan import parse_ollama_scan_stdout
|
|
|
|
|
|
def test_parse_ollama_scan_stdout_parses_host_port_models():
|
|
rows = parse_ollama_scan_stdout(
|
|
[
|
|
"host1\t11434\tllama3,mistral",
|
|
"host2\t\t-",
|
|
"# comment",
|
|
"",
|
|
]
|
|
)
|
|
|
|
assert rows
|
|
r0 = rows[0]
|
|
assert set(r0.keys()) >= {"host", "port", "models"}
|
|
|
|
# Host1 row
|
|
host1 = next(r for r in rows if r["host"] == "host1")
|
|
assert host1["port"] == "11434"
|
|
assert host1["models"] == ["llama3", "mistral"]
|
|
|
|
# Host2 defaults port and filters '-' model list
|
|
host2 = next(r for r in rows if r["host"] == "host2")
|
|
assert host2["port"] == "11434"
|
|
assert host2["models"] == []
|
|
|
|
|
|
def test_parse_ollama_scan_stdout_dedupes_by_canonical_host_and_merges_models():
|
|
# localhost and 127.0.0.1 should canonicalize to the same server;
|
|
# prefer nicer label and merge models.
|
|
rows = parse_ollama_scan_stdout(
|
|
[
|
|
"127.0.0.1\t11434\tmistral",
|
|
"localhost\t11434\tllama3",
|
|
"localhost\t11434\tllama3", # duplicate model
|
|
]
|
|
)
|
|
|
|
assert len(rows) == 1
|
|
assert rows[0]["port"] == "11434"
|
|
assert rows[0]["host"] == "localhost"
|
|
assert set(rows[0]["models"]) == {"mistral", "llama3"}
|