45 lines
1.6 KiB
Python
45 lines
1.6 KiB
Python
"""Unit tests for UI refinement, test action safety, and settings persistence."""
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
import os
|
|
import tempfile
|
|
from pathlib import Path
|
|
import pytest
|
|
|
|
from antigravity_provider.router.hermes_hub_app import do_test_profile, do_set_main, do_set_orchestrator
|
|
from antigravity_provider.router.profile_manager import ProfileAuthManager
|
|
|
|
|
|
def test_test_action_safe_on_unauthenticated():
|
|
"""Verify that testing an unauthenticated profile returns an error and never triggers OAuth/browser."""
|
|
# ag-spare-2 is unauthenticated
|
|
res = do_test_profile("antigravity", "ag-spare-2")
|
|
assert res["success"] is False
|
|
assert "не авторизован" in res["error"].lower()
|
|
|
|
|
|
def test_test_action_non_existent_profile():
|
|
"""Verify that testing a non-existent profile returns a clean error."""
|
|
res = do_test_profile("antigravity", "non_existent_profile_xyz")
|
|
assert res["success"] is False
|
|
assert "не найден" in res["error"].lower()
|
|
|
|
|
|
def test_set_main_profile_action():
|
|
"""Verify that do_set_main updates the default profile."""
|
|
# Test setting main profile
|
|
ok, msg = do_set_main("antigravity", "ag-w1")
|
|
assert ok is True
|
|
assert "ag-w1" in msg
|
|
|
|
# Verify via ProfileAuthManager
|
|
main_pid = ProfileAuthManager.get_main_profile("antigravity")
|
|
assert main_pid == "ag-w1"
|
|
|
|
|
|
def test_set_orchestrator_action():
|
|
"""Verify that do_set_orchestrator updates the router config."""
|
|
ok, msg = do_set_orchestrator("ag-orch-fallback")
|
|
assert ok is True
|
|
assert "ag-orch-fallback" in msg
|