UI update changed
This commit is contained in:
@@ -196,6 +196,20 @@ def test_register_login_and_account_view(account_tracker):
|
||||
assert me["api_keys"] == [reg["api_key"]]
|
||||
assert me["total_balance"] == pytest.approx(0.0)
|
||||
assert me["usage"]["requests"] == 0
|
||||
assert "records" not in me["usage"]
|
||||
assert "recent" not in me["usage"]
|
||||
|
||||
|
||||
def test_account_usage_endpoint_returns_records(account_tracker):
|
||||
url, ledger = account_tracker
|
||||
reg = _call(f"{url}/v1/auth/register", "POST",
|
||||
{"email": "usage@example.com", "password": "secret-123"})
|
||||
ledger.charge_request(reg["api_key"], "test-model", total_tokens=42, node_work=[("wallet-1", 1)])
|
||||
usage = _call(f"{url}/v1/account/usage", token=reg["session_token"])
|
||||
assert usage["requests"] == 1
|
||||
assert usage["total_tokens"] == 42
|
||||
assert len(usage["records"]) == 1
|
||||
assert usage["records"][0]["model"] == "test-model"
|
||||
|
||||
|
||||
def test_account_nickname_register_and_profile_update(account_tracker):
|
||||
|
||||
@@ -113,12 +113,42 @@ def test_dashboard_chat_sessions_use_delegated_handlers():
|
||||
tracker.stop()
|
||||
|
||||
assert "bindChatSessionList" in html
|
||||
assert "data-session-id=" in html
|
||||
assert "data-delete-session=" in html
|
||||
assert "dataset.sessionId" in html
|
||||
assert "dataset.deleteSession" in html
|
||||
assert '[data-session-id]' in html
|
||||
assert 'onclick="selectChatSession(' not in html
|
||||
assert 'onclick="deleteChatSession(' not in html
|
||||
|
||||
|
||||
def test_dashboard_incremental_refresh_helpers():
|
||||
tracker = TrackerServer()
|
||||
port = tracker.start()
|
||||
try:
|
||||
html = urllib.request.urlopen(
|
||||
f"http://127.0.0.1:{port}/dashboard"
|
||||
).read().decode()
|
||||
finally:
|
||||
tracker.stop()
|
||||
|
||||
assert "renderIfChanged" in html
|
||||
assert "syncKeyedList" in html
|
||||
assert "refreshBlocked" in html
|
||||
assert "patchAccountPanelView" in html
|
||||
assert "buildAccountPanelShell" in html
|
||||
assert "refreshActiveTab" in html
|
||||
assert "TAB_FETCHERS" in html
|
||||
assert "loadAccountSummary" in html
|
||||
assert "loadAccountUsage" in html
|
||||
assert "fetchOverviewTab" in html
|
||||
assert "pollCallWallIfIdle" in html
|
||||
assert "pendingChatModelRefresh" in html
|
||||
assert 'renderChatHistory(true)' in html
|
||||
assert "renderChatHistory();" not in html
|
||||
assert "refreshIfIdle" not in html
|
||||
assert "refreshAccountIfIdle" not in html
|
||||
assert "setInterval(refreshIfIdle" not in html
|
||||
|
||||
|
||||
def test_dashboard_served_by_follower():
|
||||
"""A tracker that is not the leader (unreachable peers → never elected)
|
||||
still serves the dashboard from its own replicated state."""
|
||||
|
||||
@@ -186,3 +186,24 @@ def test_qwen_preset_prices_apply_to_all_aliases(tmp_path):
|
||||
assert billing.price_for("some/other-model") == pytest.approx(0.02)
|
||||
finally:
|
||||
pass
|
||||
|
||||
|
||||
def test_qwen25_preset_price_is_ten_x_commercial_reference(tmp_path):
|
||||
"""Qwen2.5-0.5B bills at 10× ~$0.20/1M reference ($0.002/1k), not the 0.02 default."""
|
||||
import pytest
|
||||
from meshnet_tracker.server import TrackerServer, _resolve_model_preset, DEFAULT_MODEL_PRESETS
|
||||
|
||||
name, preset = _resolve_model_preset(DEFAULT_MODEL_PRESETS, "Qwen/Qwen2.5-0.5B-Instruct")
|
||||
assert name == "qwen2.5-0.5b-instruct"
|
||||
assert preset["price_per_1k_tokens"] == pytest.approx(0.002)
|
||||
|
||||
tracker = TrackerServer(billing_db=str(tmp_path / "billing.sqlite"))
|
||||
billing = tracker._billing
|
||||
assert billing is not None
|
||||
for key in (
|
||||
"qwen2.5-0.5b",
|
||||
"Qwen2.5-0.5B-Instruct",
|
||||
"Qwen/Qwen2.5-0.5B-Instruct",
|
||||
):
|
||||
assert billing.price_for(key) == pytest.approx(0.002), key
|
||||
assert billing.price_for("unrelated-model") == pytest.approx(0.02)
|
||||
|
||||
Reference in New Issue
Block a user