test descriptions
This commit is contained in:
@@ -52,6 +52,7 @@ def _report(**overrides):
|
||||
|
||||
@pytest.mark.parametrize("model_id", [FIXTURE_MODEL_A, FIXTURE_MODEL_B])
|
||||
def test_arbitrary_model_ids_survive_a_json_round_trip_verbatim(model_id):
|
||||
"Arbitrary model ids survive a json round trip verbatim\n\nTags: node, startup"
|
||||
report = _report(model_id=model_id)
|
||||
restored = CapabilityReport.from_json(report.to_json())
|
||||
|
||||
@@ -60,6 +61,7 @@ def test_arbitrary_model_ids_survive_a_json_round_trip_verbatim(model_id):
|
||||
|
||||
|
||||
def test_two_arbitrary_models_stay_distinct_without_normalization():
|
||||
"Two arbitrary models stay distinct without normalization\n\nTags: node, startup"
|
||||
a = _report(model_id=FIXTURE_MODEL_A)
|
||||
b = _report(model_id=FIXTURE_MODEL_B)
|
||||
|
||||
@@ -68,7 +70,8 @@ def test_two_arbitrary_models_stay_distinct_without_normalization():
|
||||
|
||||
|
||||
def test_capability_and_recipe_modules_have_no_model_or_kernel_branch():
|
||||
"""No vendor/model/kernel name may be a default or a code-path discriminator."""
|
||||
"No vendor/model/kernel name may be a default or a code-path discriminator.\n\nTags: node, startup"
|
||||
|
||||
forbidden = re.compile(
|
||||
r"qwen|triton|\bfla\b|flash[_-]?attn|flash[_-]?attention|rocm|nvidia|\bcuda\b",
|
||||
re.IGNORECASE,
|
||||
@@ -84,6 +87,7 @@ def test_capability_and_recipe_modules_have_no_model_or_kernel_branch():
|
||||
|
||||
|
||||
def test_device_is_an_opaque_label():
|
||||
"Device is an opaque label\n\nTags: node, startup"
|
||||
report = _report(device="some-accelerator", device_name="Vendor Accelerator XT")
|
||||
restored = CapabilityReport.from_json(report.to_json())
|
||||
|
||||
@@ -95,6 +99,7 @@ def test_device_is_an_opaque_label():
|
||||
|
||||
|
||||
def test_report_dict_has_the_stable_documented_key_set():
|
||||
"Report dict has the stable documented key set\n\nTags: node, startup"
|
||||
payload = _report(
|
||||
model_config={"num_hidden_layers": 8},
|
||||
revision="a1b2c3",
|
||||
@@ -134,6 +139,7 @@ def test_report_dict_has_the_stable_documented_key_set():
|
||||
|
||||
|
||||
def test_identity_key_pins_model_shard_recipe_and_backend():
|
||||
"Identity key pins model shard recipe and backend\n\nTags: node, startup"
|
||||
base = _report()
|
||||
|
||||
assert base.identity_key() == (
|
||||
@@ -151,6 +157,7 @@ def test_identity_key_pins_model_shard_recipe_and_backend():
|
||||
|
||||
|
||||
def test_config_fingerprint_is_stable_under_key_order_and_detects_change():
|
||||
"Config fingerprint is stable under key order and detects change\n\nTags: node, startup"
|
||||
a = config_fingerprint({"num_hidden_layers": 8, "hidden_size": 512})
|
||||
b = config_fingerprint({"hidden_size": 512, "num_hidden_layers": 8})
|
||||
c = config_fingerprint({"hidden_size": 512, "num_hidden_layers": 9})
|
||||
@@ -163,6 +170,7 @@ def test_config_fingerprint_is_stable_under_key_order_and_detects_change():
|
||||
|
||||
|
||||
def test_status_and_passed_flag():
|
||||
"Status and passed flag\n\nTags: node, startup"
|
||||
assert _report(status="passed").passed
|
||||
assert not _report(status="failed").passed
|
||||
assert not _report(status="skipped").passed
|
||||
@@ -186,12 +194,14 @@ def test_status_and_passed_flag():
|
||||
],
|
||||
)
|
||||
def test_malformed_report_fields_name_the_offending_field(overrides, expected):
|
||||
"Malformed report fields name the offending field\n\nTags: node, startup"
|
||||
with pytest.raises(CapabilityReportError) as exc:
|
||||
_report(**overrides)
|
||||
assert expected in str(exc.value)
|
||||
|
||||
|
||||
def test_unsupported_report_schema_version_is_actionable():
|
||||
"Unsupported report schema version is actionable\n\nTags: node, startup"
|
||||
payload = _report().to_dict()
|
||||
payload["schema_version"] = 99
|
||||
|
||||
@@ -203,6 +213,7 @@ def test_unsupported_report_schema_version_is_actionable():
|
||||
|
||||
|
||||
def test_missing_schema_version_is_rejected():
|
||||
"Missing schema version is rejected\n\nTags: node, startup"
|
||||
payload = _report().to_dict()
|
||||
del payload["schema_version"]
|
||||
|
||||
@@ -211,12 +222,14 @@ def test_missing_schema_version_is_rejected():
|
||||
|
||||
|
||||
def test_malformed_report_json_reports_position_not_content():
|
||||
"Malformed report json reports position not content\n\nTags: node, startup"
|
||||
with pytest.raises(CapabilityReportError) as exc:
|
||||
CapabilityReport.from_json('{"schema_version": 1,')
|
||||
assert "line 1" in str(exc.value)
|
||||
|
||||
|
||||
def test_missing_report_section_is_named():
|
||||
"Missing report section is named\n\nTags: node, startup"
|
||||
payload = _report().to_dict()
|
||||
payload["backend"] = "torch"
|
||||
|
||||
@@ -228,6 +241,7 @@ def test_missing_report_section_is_named():
|
||||
|
||||
|
||||
def test_diagnostics_redact_secret_env_values(monkeypatch):
|
||||
"Diagnostics redact secret env values\n\nTags: node, startup"
|
||||
monkeypatch.setenv("MESHNET_API_TOKEN", "super-secret-value-123")
|
||||
monkeypatch.setenv("MESHNET_MODEL_ID", "acme-labs/Widget-9000-Instruct")
|
||||
|
||||
@@ -253,6 +267,7 @@ def test_diagnostics_redact_secret_env_values(monkeypatch):
|
||||
],
|
||||
)
|
||||
def test_diagnostics_redact_credential_shaped_strings(raw):
|
||||
"Diagnostics redact credential shaped strings\n\nTags: node, startup"
|
||||
cleaned = sanitize_diagnostic(raw, environ={})
|
||||
assert capability.REDACTED in cleaned
|
||||
for secret in (
|
||||
@@ -265,6 +280,7 @@ def test_diagnostics_redact_credential_shaped_strings(raw):
|
||||
|
||||
|
||||
def test_diagnostics_strip_the_home_directory(monkeypatch, tmp_path):
|
||||
"Diagnostics strip the home directory\n\nTags: node, startup"
|
||||
monkeypatch.setenv("HOME", str(tmp_path))
|
||||
cleaned = sanitize_diagnostic(f"missing weights at {tmp_path}/models/shard", environ={})
|
||||
|
||||
@@ -273,6 +289,7 @@ def test_diagnostics_strip_the_home_directory(monkeypatch, tmp_path):
|
||||
|
||||
|
||||
def test_diagnostics_are_bounded_in_length_and_count():
|
||||
"Diagnostics are bounded in length and count\n\nTags: node, startup"
|
||||
long_line = sanitize_diagnostic("x" * 2000, environ={})
|
||||
assert len(long_line) <= capability.MAX_DIAGNOSTIC_CHARS
|
||||
|
||||
@@ -282,6 +299,7 @@ def test_diagnostics_are_bounded_in_length_and_count():
|
||||
|
||||
|
||||
def test_diagnostics_reject_non_string_entries():
|
||||
"Diagnostics reject non string entries\n\nTags: node, startup"
|
||||
with pytest.raises(CapabilityReportError, match=r"diagnostics\[1\]"):
|
||||
sanitize_diagnostics(["ok", 42], environ={})
|
||||
|
||||
@@ -290,6 +308,7 @@ def test_diagnostics_reject_non_string_entries():
|
||||
|
||||
|
||||
def test_deserializing_a_report_re_sanitizes_diagnostics(monkeypatch):
|
||||
"Deserializing a report re sanitizes diagnostics\n\nTags: node, startup"
|
||||
monkeypatch.setenv("NODE_SECRET", "leak-me-please")
|
||||
payload = _report().to_dict()
|
||||
payload["diagnostics"] = ["backend said leak-me-please"]
|
||||
@@ -302,6 +321,7 @@ def test_deserializing_a_report_re_sanitizes_diagnostics(monkeypatch):
|
||||
|
||||
|
||||
def test_packaged_manifest_loads_with_explicit_versions():
|
||||
"Packaged manifest loads with explicit versions\n\nTags: node, startup"
|
||||
manifest = load_recipe_manifest()
|
||||
|
||||
assert manifest.schema_version == RECIPE_SCHEMA_VERSION
|
||||
@@ -313,6 +333,7 @@ def test_packaged_manifest_loads_with_explicit_versions():
|
||||
|
||||
|
||||
def test_packaged_manifest_feeds_a_report():
|
||||
"Packaged manifest feeds a report\n\nTags: node, startup"
|
||||
manifest = load_recipe_manifest()
|
||||
recipe = manifest.require(recipe_manifest.DEFAULT_RECIPE_ID)
|
||||
|
||||
@@ -326,6 +347,7 @@ def test_packaged_manifest_feeds_a_report():
|
||||
|
||||
|
||||
def test_unknown_recipe_lists_available_ids():
|
||||
"Unknown recipe lists available ids\n\nTags: node, startup"
|
||||
manifest = load_recipe_manifest()
|
||||
|
||||
with pytest.raises(RecipeManifestError) as exc:
|
||||
@@ -344,6 +366,7 @@ def _write_manifest(tmp_path: Path, doc) -> Path:
|
||||
|
||||
|
||||
def test_valid_local_manifest_loads(tmp_path):
|
||||
"Valid local manifest loads\n\nTags: node, startup"
|
||||
path = _write_manifest(
|
||||
tmp_path,
|
||||
{
|
||||
@@ -367,6 +390,7 @@ def test_valid_local_manifest_loads(tmp_path):
|
||||
|
||||
|
||||
def test_unknown_manifest_schema_version_is_actionable(tmp_path):
|
||||
"Unknown manifest schema version is actionable\n\nTags: node, startup"
|
||||
path = _write_manifest(
|
||||
tmp_path,
|
||||
{
|
||||
@@ -443,6 +467,7 @@ def test_unknown_manifest_schema_version_is_actionable(tmp_path):
|
||||
],
|
||||
)
|
||||
def test_malformed_manifest_names_the_offending_field(tmp_path, doc, expected):
|
||||
"Malformed manifest names the offending field\n\nTags: node, startup"
|
||||
path = _write_manifest(tmp_path, doc)
|
||||
|
||||
with pytest.raises(RecipeManifestError) as exc:
|
||||
@@ -451,6 +476,7 @@ def test_malformed_manifest_names_the_offending_field(tmp_path, doc, expected):
|
||||
|
||||
|
||||
def test_malformed_manifest_json_reports_position_not_content(tmp_path):
|
||||
"Malformed manifest json reports position not content\n\nTags: node, startup"
|
||||
path = _write_manifest(tmp_path, '{"schema_version": 1, "catalogue_version":')
|
||||
|
||||
with pytest.raises(RecipeManifestError) as exc:
|
||||
@@ -463,11 +489,13 @@ def test_malformed_manifest_json_reports_position_not_content(tmp_path):
|
||||
|
||||
|
||||
def test_missing_manifest_file_is_actionable(tmp_path):
|
||||
"Missing manifest file is actionable\n\nTags: node, startup"
|
||||
with pytest.raises(RecipeManifestError, match="cannot read recipe manifest"):
|
||||
load_recipe_manifest(tmp_path / "nope.json")
|
||||
|
||||
|
||||
def test_manifest_round_trips_through_its_own_dict():
|
||||
"Manifest round trips through its own dict\n\nTags: node, startup"
|
||||
manifest = load_recipe_manifest()
|
||||
reparsed = parse_recipe_manifest(manifest.to_dict(), source="<memory>")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user