mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-31 19:16:29 +00:00
Systematic prune per AGENTS.md test policy, one pass over every major test tree (gateway, hermes_cli, tools, agent, run_agent, plugins, cli, cron, tui_gateway, honcho/openviking, root-level): - DELETE: source-reading tests (read_text/getsource on prod files), change-detector tests (exact catalog counts, model-name snapshots, config version literals), mock-echo tests (assert a mock returns what it was told), assertion-free/trivial tests, near-duplicate parametrizations (boundaries + one representative kept), async/sync twin duplicates, cosmetic within-file variations. - KEEP (mandatory): security/redaction/approval guards, message-role alternation invariants, prompt-caching/deterministic-call-id invariants, issue-number regression tests (deduped), E2E tests. - 6 test files deleted outright (script-style/no-assert or fully redundant); conftest.py, fakes/, fixtures/ untouched. - tests/acp/conftest.py added: autouse fixture stubs the live models.dev/GitHub/Copilot/Anthropic inventory fetches that ACP server tests performed on every session create — test_server.py 147s → 3.4s, and the tests are now genuinely hermetic. - Sleep-based slowness shrunk where safe (codex_ttfb_watchdog, compression_concurrent_fork, etc.); no wall-clock assertion tightened. Verification: full hermetic suite via scripts/run_tests.sh — 2439 files, 31,130 tests passed, 0 failed, 0 flaky retries, 315s wall (baseline: 583s wall, 13,564s subprocess CPU).
82 lines
2.6 KiB
Python
82 lines
2.6 KiB
Python
"""Smoke tests for the xAI video gen plugin — load & register surface."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import pytest
|
|
|
|
from agent import video_gen_registry
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
def _reset_registry():
|
|
video_gen_registry._reset_for_tests()
|
|
yield
|
|
video_gen_registry._reset_for_tests()
|
|
|
|
|
|
def test_xai_provider_registers():
|
|
from plugins.video_gen.xai import XAIVideoGenProvider
|
|
|
|
provider = XAIVideoGenProvider()
|
|
video_gen_registry.register_provider(provider)
|
|
|
|
assert video_gen_registry.get_provider("xai") is provider
|
|
assert provider.display_name == "xAI"
|
|
assert provider.default_model() == "grok-imagine-video"
|
|
|
|
|
|
def test_xai_resolved_credentials_threaded_through_request(monkeypatch):
|
|
"""OAuth-resolved creds must reach the HTTP layer — bug class where
|
|
``is_available()`` says yes but the request still hits with no key.
|
|
"""
|
|
import plugins.video_gen.xai as xai_plugin
|
|
|
|
monkeypatch.delenv("XAI_API_KEY", raising=False)
|
|
monkeypatch.setattr(
|
|
"tools.xai_http.resolve_xai_http_credentials",
|
|
lambda: {
|
|
"provider": "xai-oauth",
|
|
"api_key": "oauth-bearer-token",
|
|
"base_url": "https://api.x.ai/v1",
|
|
},
|
|
)
|
|
|
|
api_key, base_url = xai_plugin._resolve_xai_credentials()
|
|
assert api_key == "oauth-bearer-token"
|
|
assert base_url == "https://api.x.ai/v1"
|
|
headers = xai_plugin._xai_headers(api_key)
|
|
assert headers["Authorization"] == "Bearer oauth-bearer-token"
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_video_input_from_public_url_uses_url_field():
|
|
from plugins.video_gen.xai import _video_input_from_public_url
|
|
|
|
url = "https://files-cdn.x.ai/kRQVP6PRQlioVAUNC3GAdg/file_1faca9c3-9411-46ad-bb41-b9b8527789e6.mp4"
|
|
result = await _video_input_from_public_url(
|
|
url,
|
|
api_key="test-key",
|
|
base_url="https://api.x.ai/v1",
|
|
)
|
|
assert result == {"url": url}
|
|
|
|
|
|
def test_xai_video_image_input_blocks_credential_store_symlink(tmp_path, monkeypatch):
|
|
from plugins.video_gen.xai import _image_ref_to_xai_input
|
|
|
|
hermes_home = tmp_path / ".hermes"
|
|
hermes_home.mkdir()
|
|
auth_json = hermes_home / "auth.json"
|
|
auth_json.write_text('{"api_key":"sk-secret"}', encoding="utf-8")
|
|
image_link = hermes_home / "leak.png"
|
|
try:
|
|
image_link.symlink_to(auth_json)
|
|
except OSError as exc:
|
|
pytest.skip(f"symlink unavailable on this platform: {exc}")
|
|
|
|
monkeypatch.setenv("HERMES_HOME", str(hermes_home))
|
|
|
|
with pytest.raises(ValueError, match="credential store"):
|
|
_image_ref_to_xai_input(str(image_link))
|
|
|
|
|