test descriptions

This commit is contained in:
Dobromir Popov
2026-07-11 22:25:30 +03:00
parent 7d259d7c9b
commit 7cf8d9bcf3
43 changed files with 876 additions and 265 deletions

View File

@@ -45,6 +45,7 @@ FIXTURE_HTML = f"""
def test_parse_hf_pricing_table_extracts_repo_provider_and_prices():
"Parse hf pricing table extracts repo provider and prices\n\nTags: general"
quotes = parse_hf_pricing_table(FIXTURE_HTML)
assert len(quotes) == 3
assert quotes[0] == HfPriceQuote("zai-org/GLM-5.2", "novita", 1.40, 4.40)
@@ -52,17 +53,20 @@ def test_parse_hf_pricing_table_extracts_repo_provider_and_prices():
def test_blended_price_per_1k_tokens_is_average_of_input_output_over_1000():
"Blended price per 1k tokens is average of input output over 1000\n\nTags: general"
quote = HfPriceQuote("zai-org/GLM-5.2", "deepinfra", 0.93, 3.00)
assert quote.blended_price_per_1k_tokens() == (0.93 + 3.00) / 2 / 1000
def test_cheapest_matching_quote_picks_lowest_blended_price_among_aliases():
"Cheapest matching quote picks lowest blended price among aliases\n\nTags: general"
quotes = parse_hf_pricing_table(FIXTURE_HTML)
cheapest = cheapest_matching_quote(quotes, ["zai-org/GLM-5.2"])
assert cheapest.provider == "deepinfra"
def test_cheapest_matching_quote_honors_repo_provider_scoped_alias():
"Cheapest matching quote honors repo provider scoped alias\n\nTags: general"
quotes = parse_hf_pricing_table(FIXTURE_HTML)
# Only the novita deployment was human-verified as comparable for this
# alias — the cheaper deepinfra row for the same repo must not match.
@@ -71,16 +75,19 @@ def test_cheapest_matching_quote_honors_repo_provider_scoped_alias():
def test_cheapest_matching_quote_returns_none_when_no_alias_matches():
"Cheapest matching quote returns none when no alias matches\n\nTags: general"
quotes = parse_hf_pricing_table(FIXTURE_HTML)
assert cheapest_matching_quote(quotes, ["someone/unrelated-model"]) is None
def test_cheapest_matching_quote_returns_none_for_empty_aliases():
"Cheapest matching quote returns none for empty aliases\n\nTags: general"
quotes = parse_hf_pricing_table(FIXTURE_HTML)
assert cheapest_matching_quote(quotes, []) is None
def test_refresh_preset_price_end_to_end_with_injected_fetch():
"Refresh preset price end to end with injected fetch\n\nTags: general"
preset = {"hf_repo": "zai-org/GLM-5.2", "hf_aliases": ["zai-org/GLM-5.2"]}
result = refresh_preset_price(
model_name="glm-5.2",
@@ -98,6 +105,7 @@ def test_refresh_preset_price_end_to_end_with_injected_fetch():
def test_refresh_preset_price_skips_presets_without_hf_aliases():
"Refresh preset price skips presets without hf aliases\n\nTags: general"
preset = {"hf_repo": "unsloth/Kimi-K2.7-Code"}
result = refresh_preset_price(
model_name="kimi-k2.7",
@@ -109,6 +117,7 @@ def test_refresh_preset_price_skips_presets_without_hf_aliases():
def test_refresh_preset_price_falls_back_silently_on_fetch_failure():
"Refresh preset price falls back silently on fetch failure\n\nTags: general"
preset = {"hf_repo": "zai-org/GLM-5.2", "hf_aliases": ["zai-org/GLM-5.2"]}
def _boom(url: str) -> str:
@@ -121,6 +130,7 @@ def test_refresh_preset_price_falls_back_silently_on_fetch_failure():
def test_refresh_preset_price_falls_back_silently_when_no_match_found():
"Refresh preset price falls back silently when no match found\n\nTags: general"
preset = {"hf_repo": "zai-org/GLM-5.2", "hf_aliases": ["someone/unrelated-model"]}
result = refresh_preset_price(
model_name="glm-5.2",
@@ -132,6 +142,7 @@ def test_refresh_preset_price_falls_back_silently_when_no_match_found():
def test_hf_pricing_log_persists_and_is_queryable(tmp_path):
"Hf pricing log persists and is queryable\n\nTags: persistence"
db_path = str(tmp_path / "hf_pricing_log.sqlite")
log = HfPricingLog(db_path=db_path)
log.record_change(
@@ -151,6 +162,7 @@ def test_hf_pricing_log_persists_and_is_queryable(tmp_path):
def test_preset_price_keys_cover_name_repo_and_aliases():
"Preset price keys cover name repo and aliases\n\nTags: general"
from meshnet_tracker.server import _preset_price_keys
preset = {
@@ -167,7 +179,8 @@ def test_preset_price_keys_cover_name_repo_and_aliases():
def test_qwen_preset_prices_apply_to_all_aliases(tmp_path):
"""Requests naming the repo id (what nodes register) bill at the preset price."""
"Requests naming the repo id (what nodes register) bill at the preset price.\n\nTags: general"
from meshnet_tracker.server import TrackerServer
import pytest
@@ -189,7 +202,7 @@ def test_qwen_preset_prices_apply_to_all_aliases(tmp_path):
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."""
"Qwen2.\n\nTags: general"
import pytest
from meshnet_tracker.server import TrackerServer, _resolve_model_preset, DEFAULT_MODEL_PRESETS