Skip to content

test(scripts): add 44 tests for genai audio_apis.py#1894

Merged
jsboige merged 1 commit into
mainfrom
test/genai-audio-apis
May 30, 2026
Merged

test(scripts): add 44 tests for genai audio_apis.py#1894
jsboige merged 1 commit into
mainfrom
test/genai-audio-apis

Conversation

@jsboige
Copy link
Copy Markdown
Owner

@jsboige jsboige commented May 30, 2026

Summary

44 tests for scripts/genai-stack/commands/audio_apis.py (LIVE: imported by genai.py).

Test zones (6 classes, 44 tests)

Zone Tests Key invariants
AUDIO_API_SERVICES 5 5 services, no duplicates, all strings
GPU_ALLOCATION 7 4/5 services allocated (funasr-api=None), 2 distinct GPUs
GPU_CONFLICTS 6 All allocated services in their GPU conflict list
_make_silence_wav 12 Valid WAV structure (RIFF/WAVE/PCM/16kHz/mono), 32044 bytes, all silence
_get_auth_headers 9 Content-Type always present, Bearer token from .env file, comments ignored
Cross-invariants 5 GPU groups, conflict containment, allocation consistency

Notable finding

_get_auth_headers normalizes service names via replace("-","_").upper() + "_API_KEY", producing double-_API keys for services ending in -api (e.g. whisper-apiWHISPER_API_API_KEY). This is documented in tests but not fixed (not our scope).

Excluded (network/Docker I/O)

get_container_status, get_all_audio_status, start_service, stop_service, switch_to_service, test_service, e2e_test_service, build_service, show_logs — all require live Docker containers and HTTP endpoints.

Test results

44 passed in 0.11s
Full suite: 1125 passed, 0 regression

po-2024 test coverage (cycles 69-75)

Cycle Script Tests PR
69 validate_pr_notebooks 34 #1878
70 weekly_digest 19 #1880
71 validate_sc_notebooks 56 #1882
72 update_sc_navigation 42 #1885
73 genai-stack/config.py 54 #1886
74 genai-stack/commands/validate.py 34 #1892
75 genai-stack/commands/audio_apis.py 44 THIS
Total 283

Tests for AUDIO_API_SERVICES (5), GPU_ALLOCATION (7), GPU_CONFLICTS (6), _make_silence_wav (12), _get_auth_headers (9), cross-invariants (5).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copy link
Copy Markdown
Collaborator

@clusterManager-Myia clusterManager-Myia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Hermes] — APPROVED

PR: test(scripts): add 44 tests for genai audio_apis.py
SHA reviewed: 8b1773 (HEAD)

Checklist

  • Security scan: CLEAN (API_KEY/BEARER matches are mock test values, not real credentials)
  • Cross-repo impact: None
  • Change type: New test file — 355 lines, 44 tests covering pure logic of audio_apis.py

Verification

  • Tests cover: AUDIO_API_SERVICES (list/count/uniqueness), GPU_ALLOCATION (mapping consistency), GPU_CONFLICTS (coverage), _make_silence_wav (WAV header, data integrity, PCM format), _get_auth_headers (env/file token loading, fallback chain, Bearer prefix)
  • Network-dependent functions correctly excluded (documented in docstring)
  • Mock strategy is clean: patch.dict for env vars, Path mocking for .env file reads
  • 2 hardcoded magic numbers noted in docstrings (5 services, 2 GPUs) — acceptable for constant validation tests

Concerns

None. Well-structured test suite with good coverage of pure logic. sys.path.insert hack is consistent with other test files in the repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants