Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,10 @@ def test_prompt_alias_is_not_registered(self):
assert retrieve_handler("agenta:builtin:prompt:v0") is None
assert retrieve_interface("agenta:builtin:prompt:v0") is None

def test_agent_alias_is_not_registered(self):
def test_agent_interface_is_registered_without_handler(self):
# The agent builtin ships an interface (schemas) but no in-process handler:
# the agent runs in the sidecar, not via a registered SDK callable.
assert retrieve_handler("agenta:builtin:agent:v0") is None
assert retrieve_interface("agenta:builtin:agent:v0") is None
revision = retrieve_interface("agenta:builtin:agent:v0")
assert isinstance(revision, WorkflowRevisionData)
assert revision.uri == "agenta:builtin:agent:v0"
15 changes: 10 additions & 5 deletions services/oss/tests/pytest/integration/agent/conftest.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
"""Integration fixtures: a fake httpx client for the tool/secret resolvers.

These tests wire the real resolver code against a mocked HTTP boundary (no live backend, no
respx/pytest-httpx dependency). ``install_http`` patches, in a given resolver module, the two
``client`` helpers (``agenta_api_base`` / ``request_authorization``) plus ``httpx.AsyncClient``,
and returns a ``capture`` dict the test can assert the outgoing request against.
respx/pytest-httpx dependency). ``install_http`` patches the two ``PlatformConnection`` helpers
(``_derive_base_url`` / ``_derive_authorization`` in the SDK platform connection module) plus
``httpx.AsyncClient`` in the given SDK platform module that performs the HTTP, and returns a
``capture`` dict the test can assert the outgoing request against.
"""

from __future__ import annotations
Expand All @@ -13,6 +14,8 @@

import pytest

from agenta.sdk.agents.platform import connection as platform_connection


class _FakeResponse:
def __init__(self, status_code: int, payload: Any, text: Optional[str]) -> None:
Expand Down Expand Up @@ -63,8 +66,10 @@ def _install(
authorization: Optional[str] = "Access tok",
) -> Dict[str, Any]:
capture: Dict[str, Any] = {}
monkeypatch.setattr(module, "agenta_api_base", lambda: api_base)
monkeypatch.setattr(module, "request_authorization", lambda: authorization)
monkeypatch.setattr(platform_connection, "_derive_base_url", lambda: api_base)
monkeypatch.setattr(
platform_connection, "_derive_authorization", lambda: authorization
)
response = _FakeResponse(status, payload, text)
monkeypatch.setattr(
module.httpx,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@

import pytest

from oss.src.agent import secrets
from oss.src.agent.secrets import resolve_harness_secrets
from agenta.sdk.agents.platform import secrets as platform_secrets

pytestmark = pytest.mark.integration


async def test_no_api_base_returns_empty(install_http):
install_http(secrets, api_base=None)
install_http(platform_secrets, api_base=None)
assert await resolve_harness_secrets() == {}


async def test_maps_only_provider_keys_with_dedupe(install_http):
install_http(
secrets,
platform_secrets,
status=200,
payload=[
{
Expand Down Expand Up @@ -55,10 +55,10 @@ async def test_maps_only_provider_keys_with_dedupe(install_http):


async def test_http_error_returns_empty(install_http):
install_http(secrets, status=400)
install_http(platform_secrets, status=400)
assert await resolve_harness_secrets() == {}


async def test_network_exception_returns_empty(install_http):
install_http(secrets, raises=RuntimeError("network down"))
install_http(platform_secrets, raises=RuntimeError("network down"))
assert await resolve_harness_secrets() == {}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
)

from oss.src.agent.tools import resolve_tools
from oss.src.agent.tools import gateway
from agenta.sdk.agents.platform import gateway

pytestmark = pytest.mark.integration

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
import pytest

from oss.src.agent.tools import secrets
from agenta.sdk.agents.platform import secrets as platform_secrets

pytestmark = pytest.mark.integration


async def test_named_secrets_are_resolved_by_tools_adapter(install_http):
capture = install_http(
secrets,
platform_secrets,
payload={"secrets": {"TOKEN": "value", "EMPTY": None}},
)

Expand All @@ -28,12 +29,12 @@ async def test_named_secrets_are_resolved_by_tools_adapter(install_http):


async def test_named_secrets_without_api_base_return_empty(install_http):
install_http(secrets, api_base=None)
install_http(platform_secrets, api_base=None)

assert await secrets.resolve_named_secrets(["TOKEN"]) == {}


async def test_named_secret_http_failure_returns_empty(install_http):
install_http(secrets, status=500)
install_http(platform_secrets, status=500)

assert await secrets.resolve_named_secrets(["TOKEN"]) == {}
Loading