mirror of
https://github.com/MervinPraison/PraisonAI.git
synced 2026-11-07 04:35:58 -10:00
test(gateway): cover misspelled gateway block at load time (#3050)
Adds load_gateway_config integration coverage for the #3050 validation path and documents load-time gateway block checks in the example. Supersedes #3060; core fix landed in #3079. Co-authored-by: botbikamordehai2-sketch <[email protected]>
This commit is contained in:
1 parent
11bcd13797
commit
d3b99876d6
2 files changed
+20
-1
No files matched your search
@@ -7,7 +7,8 @@ multiple agents and managing real-time communication.
|
||||
|
||||
from praisonaiagents import Agent, GatewayConfig, SessionConfig
|
||||
|
||||
# Configure the gateway
|
||||
# Configure the gateway using the typed SDK GatewayConfig.
|
||||
# In gateway.yaml, the optional ``gateway:`` block is validated at load time (#3050).
|
||||
gateway_config = GatewayConfig(
|
||||
host="127.0.0.1",
|
||||
port=8765,
|
||||
|
||||
@@ -134,6 +134,24 @@ class TestWebSocketIntegration:
|
||||
assert "channels" in cfg
|
||||
assert cfg["channels"]["telegram"]["token"] == "test123"
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_gateway_config_rejects_misspelled_server_block(self, tmp_path):
|
||||
"""Misspelled ``gateway:`` server settings fail at load time (#3050)."""
|
||||
try:
|
||||
from praisonai.gateway.server import WebSocketGateway
|
||||
except ImportError:
|
||||
pytest.skip("praisonai.gateway not available")
|
||||
|
||||
bad_config = tmp_path / "bad.yaml"
|
||||
bad_config.write_text(
|
||||
"agents:\n bot:\n instructions: hi\n"
|
||||
"channels:\n telegram:\n token: test123\n"
|
||||
"gateway:\n drain_timout: 30\n"
|
||||
)
|
||||
|
||||
with pytest.raises(ValueError, match="drain_timout"):
|
||||
WebSocketGateway.load_gateway_config(str(bad_config))
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_websocket_connect_and_message(self):
|
||||
"""Test actual WebSocket connection to gateway server.
|
||||
|
||||
Reference in new issue
Block a user