test descriptions
This commit is contained in:
@@ -15,11 +15,13 @@ from unittest.mock import MagicMock, patch
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
def test_curated_models_list_is_non_empty():
|
||||
"Curated models list is non empty\n\nTags: general"
|
||||
from meshnet_node.model_catalog import CURATED_MODELS
|
||||
assert len(CURATED_MODELS) >= 5
|
||||
|
||||
|
||||
def test_model_preset_vram_for_quant():
|
||||
"Model preset vram for quant\n\nTags: general"
|
||||
from meshnet_node.model_catalog import CURATED_MODELS
|
||||
|
||||
m = next(m for m in CURATED_MODELS if "Llama-3-70B" in m.name)
|
||||
@@ -30,6 +32,7 @@ def test_model_preset_vram_for_quant():
|
||||
|
||||
|
||||
def test_model_preset_fits_vram():
|
||||
"Model preset fits vram\n\nTags: general"
|
||||
from meshnet_node.model_catalog import CURATED_MODELS
|
||||
|
||||
small = next(m for m in CURATED_MODELS if m.vram_nf4 < 10)
|
||||
@@ -38,6 +41,7 @@ def test_model_preset_fits_vram():
|
||||
|
||||
|
||||
def test_recommended_quant_respects_vram():
|
||||
"Recommended quant respects vram\n\nTags: general"
|
||||
from meshnet_node.model_catalog import CURATED_MODELS
|
||||
|
||||
m = next(m for m in CURATED_MODELS if "Llama-3-70B" in m.name)
|
||||
@@ -49,6 +53,7 @@ def test_recommended_quant_respects_vram():
|
||||
|
||||
|
||||
def test_models_with_insufficient_vram_are_marked(monkeypatch):
|
||||
"Models with insufficient vram are marked\n\nTags: general"
|
||||
from meshnet_node import wizard as wiz
|
||||
|
||||
# Simulate 6 GB GPU
|
||||
@@ -70,11 +75,13 @@ def test_models_with_insufficient_vram_are_marked(monkeypatch):
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
def test_load_config_returns_none_when_missing(tmp_path):
|
||||
"Load config returns none when missing\n\nTags: general"
|
||||
from meshnet_node.config import load_config
|
||||
assert load_config(tmp_path / "nonexistent.json") is None
|
||||
|
||||
|
||||
def test_save_and_load_config_roundtrip(tmp_path):
|
||||
"Save and load config roundtrip\n\nTags: general"
|
||||
from meshnet_node.config import save_config, load_config
|
||||
|
||||
cfg = {"model_hf_repo": "test/model", "quantization": "nf4", "tracker_url": "http://localhost:8080"}
|
||||
@@ -86,6 +93,7 @@ def test_save_and_load_config_roundtrip(tmp_path):
|
||||
|
||||
|
||||
def test_save_config_creates_parent_dirs(tmp_path):
|
||||
"Save config creates parent dirs\n\nTags: general"
|
||||
from meshnet_node.config import save_config, load_config
|
||||
|
||||
nested = tmp_path / "deep" / "nested" / "config.json"
|
||||
@@ -95,6 +103,7 @@ def test_save_config_creates_parent_dirs(tmp_path):
|
||||
|
||||
|
||||
def test_merge_cli_overrides_applies_non_none_values():
|
||||
"Merge cli overrides applies non none values\n\nTags: general"
|
||||
from meshnet_node.config import merge_cli_overrides
|
||||
|
||||
base = {"tracker_url": "http://a:8080", "quantization": "nf4", "port": 7000}
|
||||
@@ -109,6 +118,7 @@ def test_merge_cli_overrides_applies_non_none_values():
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
def test_print_models_table_runs_without_error(capsys, monkeypatch):
|
||||
"Print models table runs without error\n\nTags: general"
|
||||
from meshnet_node import wizard as wiz
|
||||
|
||||
monkeypatch.setattr(wiz, "_detect_gpus", lambda: [{"index": 0, "name": "GPU", "vram_gb": 24.0, "backend": "cuda"}])
|
||||
@@ -118,6 +128,7 @@ def test_print_models_table_runs_without_error(capsys, monkeypatch):
|
||||
|
||||
|
||||
def test_wizard_writes_config_on_happy_path(tmp_path, monkeypatch):
|
||||
"Wizard writes config on happy path\n\nTags: general"
|
||||
from meshnet_node import wizard as wiz
|
||||
from meshnet_node.config import load_config, save_config
|
||||
|
||||
@@ -145,6 +156,7 @@ def test_wizard_writes_config_on_happy_path(tmp_path, monkeypatch):
|
||||
|
||||
|
||||
def test_wizard_raises_keyboard_interrupt_on_ctrl_c(monkeypatch):
|
||||
"Wizard raises keyboard interrupt on ctrl c\n\nTags: general"
|
||||
from meshnet_node import wizard as wiz
|
||||
|
||||
gpus = [{"index": 0, "name": "RTX 4090", "vram_gb": 24.0, "backend": "cuda"}]
|
||||
@@ -169,6 +181,7 @@ def test_wizard_raises_keyboard_interrupt_on_ctrl_c(monkeypatch):
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
def test_is_interactive_tty_false_when_not_tty(monkeypatch):
|
||||
"Is interactive tty false when not tty\n\nTags: general"
|
||||
from meshnet_node import dashboard as dash
|
||||
|
||||
monkeypatch.setattr(sys.stdout, "isatty", lambda: False)
|
||||
@@ -176,7 +189,7 @@ def test_is_interactive_tty_false_when_not_tty(monkeypatch):
|
||||
|
||||
|
||||
def test_dashboard_plain_fallback_on_keyboard_interrupt(monkeypatch):
|
||||
"""Plain loop exits cleanly when Ctrl-C is raised."""
|
||||
"Plain loop exits cleanly when Ctrl-C is raised.\n\nTags: general"
|
||||
from meshnet_node import dashboard as dash
|
||||
|
||||
node = MagicMock()
|
||||
@@ -199,6 +212,7 @@ def test_dashboard_plain_fallback_on_keyboard_interrupt(monkeypatch):
|
||||
|
||||
|
||||
def test_ema_updates_correctly():
|
||||
"Ema updates correctly\n\nTags: general"
|
||||
from meshnet_node.dashboard import _EMA
|
||||
|
||||
ema = _EMA(alpha=1.0) # alpha=1.0 → always takes latest sample
|
||||
@@ -213,7 +227,7 @@ def test_ema_updates_correctly():
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
def test_models_command_prints_table(capsys, monkeypatch):
|
||||
"""meshnet-node models prints the curated table and exits 0."""
|
||||
"meshnet-node models prints the curated table and exits 0.\n\nTags: general"
|
||||
from meshnet_node import wizard as wiz
|
||||
|
||||
monkeypatch.setattr(wiz, "_detect_gpus", lambda: [])
|
||||
@@ -231,6 +245,7 @@ def test_models_command_prints_table(capsys, monkeypatch):
|
||||
|
||||
|
||||
def test_config_command_no_config_exits_1(tmp_path, monkeypatch):
|
||||
"Config command no config exits 1\n\nTags: general"
|
||||
from meshnet_node import config as cfg_mod
|
||||
from meshnet_node.cli import main
|
||||
|
||||
@@ -245,6 +260,7 @@ def test_config_command_no_config_exits_1(tmp_path, monkeypatch):
|
||||
|
||||
|
||||
def test_config_command_prints_saved_config(tmp_path, monkeypatch, capsys):
|
||||
"Config command prints saved config\n\nTags: general"
|
||||
from meshnet_node import config as cfg_mod
|
||||
from meshnet_node.config import save_config
|
||||
from meshnet_node.cli import main
|
||||
@@ -268,7 +284,7 @@ def test_config_command_prints_saved_config(tmp_path, monkeypatch, capsys):
|
||||
|
||||
|
||||
def test_detect_num_layers_returns_catalog_value_without_network(monkeypatch):
|
||||
"""detect_num_layers uses the curated catalog first — no network call."""
|
||||
"detect_num_layers uses the curated catalog first — no network call.\n\nTags: general"
|
||||
from meshnet_node.model_catalog import detect_num_layers
|
||||
|
||||
# Qwen2.5-0.5B is in the catalog with 24 layers
|
||||
@@ -277,6 +293,7 @@ def test_detect_num_layers_returns_catalog_value_without_network(monkeypatch):
|
||||
|
||||
|
||||
def test_detect_num_layers_returns_none_on_error(monkeypatch):
|
||||
"Detect num layers returns none on error\n\nTags: general"
|
||||
from meshnet_node.model_catalog import detect_num_layers
|
||||
|
||||
# Monkeypatch AutoConfig to raise
|
||||
@@ -286,7 +303,7 @@ def test_detect_num_layers_returns_none_on_error(monkeypatch):
|
||||
|
||||
|
||||
def test_startup_auto_detects_shard_range(monkeypatch, tmp_path):
|
||||
"""When shard_start/end are None, startup reads layer count from catalog."""
|
||||
"When shard_start/end are None, startup reads layer count from catalog.\n\nTags: general"
|
||||
from meshnet_node import startup as su
|
||||
from meshnet_node.model_catalog import detect_num_layers
|
||||
|
||||
@@ -325,7 +342,7 @@ def test_startup_auto_detects_shard_range(monkeypatch, tmp_path):
|
||||
|
||||
|
||||
def test_legacy_start_subcommand_accepted(monkeypatch):
|
||||
"""meshnet-node start --tracker http://... does not crash on arg parsing."""
|
||||
"meshnet-node start --tracker http://...\n\nTags: general"
|
||||
from meshnet_node.cli import main
|
||||
|
||||
def fake_run_startup(*args, **kwargs):
|
||||
@@ -358,7 +375,7 @@ def test_legacy_start_subcommand_accepted(monkeypatch):
|
||||
|
||||
|
||||
def test_legacy_start_treats_repo_model_as_model_id(monkeypatch):
|
||||
"""`meshnet-node start --model org/repo` enters the HF model startup path."""
|
||||
"`meshnet-node start --model org/repo` enters the HF model startup path.\n\nTags: general"
|
||||
from meshnet_node.cli import main
|
||||
|
||||
captured = {}
|
||||
@@ -389,7 +406,7 @@ def test_legacy_start_treats_repo_model_as_model_id(monkeypatch):
|
||||
|
||||
|
||||
def test_legacy_start_catalog_model_with_pinned_shards(monkeypatch):
|
||||
"""Catalog model names accept --shard-start/--shard-end without --model-id."""
|
||||
"Catalog model names accept --shard-start/--shard-end without --model-id.\n\nTags: general"
|
||||
from meshnet_node.cli import main
|
||||
|
||||
captured = {}
|
||||
@@ -424,7 +441,7 @@ def test_legacy_start_catalog_model_with_pinned_shards(monkeypatch):
|
||||
|
||||
|
||||
def test_legacy_start_model_id_alias_for_catalog_name(monkeypatch):
|
||||
"""--model-id with a catalog name routes through the tracker preset path."""
|
||||
"--model-id with a catalog name routes through the tracker preset path.\n\nTags: general"
|
||||
from meshnet_node.cli import main
|
||||
|
||||
captured = {}
|
||||
@@ -455,7 +472,7 @@ def test_legacy_start_model_id_alias_for_catalog_name(monkeypatch):
|
||||
|
||||
|
||||
def test_legacy_start_hf_repo_with_pinned_shards(monkeypatch):
|
||||
"""HF repo --model with pinned shards still enters the torch startup path."""
|
||||
"HF repo --model with pinned shards still enters the torch startup path.\n\nTags: general"
|
||||
from meshnet_node.cli import main
|
||||
|
||||
captured = {}
|
||||
@@ -490,7 +507,7 @@ def test_legacy_start_hf_repo_with_pinned_shards(monkeypatch):
|
||||
|
||||
|
||||
def test_legacy_start_falls_back_to_env_tracker_and_model(monkeypatch):
|
||||
"""`meshnet-node start` uses env defaults when tracker/model flags are omitted."""
|
||||
"`meshnet-node start` uses env defaults when tracker/model flags are omitted.\n\nTags: general"
|
||||
import importlib
|
||||
|
||||
from meshnet_node import config as config_mod
|
||||
@@ -532,7 +549,7 @@ def test_legacy_start_falls_back_to_env_tracker_and_model(monkeypatch):
|
||||
|
||||
|
||||
def test_legacy_start_without_port_uses_next_available_port(monkeypatch):
|
||||
"""Omitting --port skips an occupied default port before startup loads the model."""
|
||||
"Omitting --port skips an occupied default port before startup loads the model.\n\nTags: general"
|
||||
from meshnet_node.cli import main
|
||||
|
||||
captured = {}
|
||||
@@ -569,7 +586,7 @@ def test_legacy_start_without_port_uses_next_available_port(monkeypatch):
|
||||
|
||||
|
||||
def test_default_cli_passes_advertise_host(monkeypatch):
|
||||
"""The documented no-subcommand LAN flag reaches startup."""
|
||||
"The documented no-subcommand LAN flag reaches startup.\n\nTags: general"
|
||||
from meshnet_node.cli import main
|
||||
|
||||
saved = {
|
||||
@@ -613,7 +630,7 @@ def test_default_cli_passes_advertise_host(monkeypatch):
|
||||
|
||||
|
||||
def test_default_cli_passes_force_cpu(monkeypatch):
|
||||
"""`meshnet-node --cpu` forwards force_cpu into run_startup."""
|
||||
"`meshnet-node --cpu` forwards force_cpu into run_startup.\n\nTags: general"
|
||||
from meshnet_node.cli import main
|
||||
|
||||
captured = {}
|
||||
|
||||
Reference in New Issue
Block a user