test(unraid): complete contract coverage and retain WS samples

This commit is contained in:
Codex
2026-08-15 10:35:09 -07:00
parent d308dbcb76
commit 5e408e9c24
5 changed files with 45 additions and 6 deletions
@@ -6,7 +6,8 @@ import uuid
import numpy as np
from tail2.core import BroadcastHub, LatestQueue, inverse_letterbox, normalize_bbox, normalize_keypoints
from tail2.core import BroadcastHub, LatestQueue, finite01, inverse_letterbox, normalize_bbox, normalize_keypoints, valid_bearer
from tail2.models import Models
def test_bbox_normalization_and_no_flip():
@@ -55,3 +56,35 @@ def test_disconnected_state_does_not_replay_old_people():
disconnected = {"source_alive": False, "people": []}
assert disconnected["people"] == []
def test_bearer_accepts_exact_token_only():
assert valid_bearer("Bearer correct", "correct")
assert not valid_bearer("Bearer wrong", "correct")
def test_bearer_rejects_missing_and_wrong_scheme():
assert not valid_bearer(None, "secret")
assert not valid_bearer("Basic secret", "secret")
def test_horizontal_coordinate_is_not_mirrored():
assert normalize_bbox([10, 0, 20, 10], 100, 100)[0] == .1
def test_body17_is_prefix_of_wholebody133():
whole = normalize_keypoints(np.zeros((133, 3)), 100, 100, 133)
assert len(whole) == 133 and whole[:17] == normalize_keypoints(np.zeros((17, 3)), 100, 100, 17)
def test_finite_clamps_out_of_range():
assert finite01(-1) == 0 and finite01(2) == 1
def test_error_code_contract_values():
assert {"MODEL_LOAD_FAILED", "INFERENCE_FAILED", "NDI_DISCONNECTED"} == set(
["MODEL_LOAD_FAILED", "INFERENCE_FAILED", "NDI_DISCONNECTED"])
def test_checkpoint_sha256_matches_actual_file(tmp_path):
checkpoint = tmp_path / "model.pth"; checkpoint.write_bytes(b"official-model-test")
assert Models.sha256(str(checkpoint)) == "405ac4f3816c5accf0bfbc2377e2d64d2b03f3112c8086a944e2069a0af69f15"