1
0

[kimi] Break up _dispatch_via_gitea() into helper functions (#1136) (#1183)

This commit is contained in:
2026-03-23 21:40:17 +00:00
parent 74bf0606a9
commit 7aa48b4e22
26 changed files with 195 additions and 115 deletions

View File

@@ -7,19 +7,18 @@ from unittest.mock import AsyncMock, patch
import pytest
pytestmark = pytest.mark.unit
from timmy.sovereignty.metrics import (
ALL_EVENT_TYPES,
SovereigntyMetricsStore,
emit_sovereignty_event,
get_cost_per_hour,
get_metrics_store,
get_skills_crystallized,
get_sovereignty_pct,
record,
)
pytestmark = pytest.mark.unit
@pytest.fixture
def store(tmp_path):
@@ -130,7 +129,6 @@ class TestGetSovereigntyPct:
def test_time_window_filters_old_events(self, store, tmp_path):
"""Events outside the time window are excluded."""
# Insert an event with a very old timestamp directly
import json
import sqlite3
from contextlib import closing
@@ -230,24 +228,27 @@ class TestGetSnapshot:
class TestModuleLevelFunctions:
def test_record_and_get_sovereignty_pct(self, tmp_path):
with patch("timmy.sovereignty.metrics._store", None), patch(
"timmy.sovereignty.metrics.DB_PATH", tmp_path / "fn_test.db"
with (
patch("timmy.sovereignty.metrics._store", None),
patch("timmy.sovereignty.metrics.DB_PATH", tmp_path / "fn_test.db"),
):
record("decision_rule_hit")
pct = get_sovereignty_pct("decision")
assert pct == 100.0
def test_get_cost_per_hour_module_fn(self, tmp_path):
with patch("timmy.sovereignty.metrics._store", None), patch(
"timmy.sovereignty.metrics.DB_PATH", tmp_path / "fn_test2.db"
with (
patch("timmy.sovereignty.metrics._store", None),
patch("timmy.sovereignty.metrics.DB_PATH", tmp_path / "fn_test2.db"),
):
record("api_cost", {"usd": 0.5})
cost = get_cost_per_hour()
assert cost > 0.0
def test_get_skills_crystallized_module_fn(self, tmp_path):
with patch("timmy.sovereignty.metrics._store", None), patch(
"timmy.sovereignty.metrics.DB_PATH", tmp_path / "fn_test3.db"
with (
patch("timmy.sovereignty.metrics._store", None),
patch("timmy.sovereignty.metrics.DB_PATH", tmp_path / "fn_test3.db"),
):
record("skill_crystallized")
count = get_skills_crystallized()