Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
59 lines
1.6 KiB
Python
59 lines
1.6 KiB
Python
"""Tests for leaderboard.py prior application."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import sqlite3
|
|
from pathlib import Path
|
|
from unittest.mock import MagicMock
|
|
|
|
import pytest
|
|
|
|
import leaderboard
|
|
|
|
ROOT = Path(__file__).resolve().parent.parent
|
|
SCHEMA_SQL = (ROOT / "config" / "schema.sql").read_text()
|
|
|
|
|
|
def _make_db(tmp_path):
|
|
db = tmp_path / "test.db"
|
|
conn = sqlite3.connect(str(db))
|
|
conn.executescript(SCHEMA_SQL)
|
|
conn.row_factory = sqlite3.Row
|
|
return conn
|
|
|
|
|
|
def test_apply_priors_threads_provider_from_caller(tmp_path, monkeypatch):
|
|
"""set_leaderboard receives the provider passed by the caller."""
|
|
conn = _make_db(tmp_path)
|
|
conn.execute(
|
|
"""
|
|
INSERT INTO models (
|
|
model_id, provider, base_model_id, availability, last_updated
|
|
) VALUES ('gemma-4-31b', 'other-vendor', 'gemma-4-31b', 'active', '2026-01-01T00:00:00+00:00')
|
|
"""
|
|
)
|
|
conn.execute(
|
|
"""
|
|
INSERT INTO proficiency (
|
|
model_id, provider, category, blended_score, source, last_updated
|
|
) VALUES ('gemma-4-31b', 'other-vendor', 'coding_general', 0.5, 'self_eval', '2026-01-01T00:00:00+00:00')
|
|
"""
|
|
)
|
|
conn.commit()
|
|
|
|
calls = []
|
|
monkeypatch.setattr(leaderboard, "set_leaderboard", lambda *a, **kw: calls.append((a, kw)))
|
|
monkeypatch.setattr(leaderboard, "recompute_category", lambda *a, **kw: None)
|
|
|
|
cfg = MagicMock()
|
|
leaderboard.apply_priors(
|
|
conn,
|
|
cfg,
|
|
{"gemma-4-31b": ["gemma-4-31b"]},
|
|
{"gemma-4-31b": {"coding_general": 0.95}},
|
|
"other-vendor",
|
|
)
|
|
|
|
assert len(calls) == 1
|
|
assert calls[0][0][3] == "other-vendor"
|