Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

1.1 KB
Raw Blame
from unittest.mock import MagicMock
from uuid import UUID

import pytest
from sqlalchemy.orm import Session

from controllers.console.agent import app_helpers
from models.model import App, AppMode
from tests.helpers.unit.model_factories import make_app


def _app() -> App:
    return make_app(name="Agent App", mode=AppMode.AGENT, icon_type=None)


def test_resolve_agent_runtime_app_model_reuses_caller_session(
    monkeypatch: pytest.MonkeyPatch, unbound_session: Session
) -> None:
    session = unbound_session
    app = _app()
    service = MagicMock()
    service.get_agent_runtime_app_model.return_value = app
    service_factory = MagicMock(return_value=service)
    monkeypatch.setattr(app_helpers, "AgentRosterService", service_factory)

    result = app_helpers.resolve_agent_runtime_app_model(
        session=session,
        tenant_id="tenant-1",
        agent_id=UUID("00000000-0000-0000-0000-000000000001"),
    )

    assert result is app
    service_factory.assert_called_once_with(session)
    service.get_agent_runtime_app_model.assert_called_once_with(
        tenant_id="tenant-1",
        agent_id="00000000-0000-0000-0000-000000000001",
    )