mirror of
https://github.com/langgenius/dify.git
synced 2026-05-13 08:57:28 +08:00
51 lines
1.5 KiB
Python
51 lines
1.5 KiB
Python
import os
|
|
import subprocess
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
|
|
PROJECT_ROOT = Path(__file__).resolve().parents[3]
|
|
|
|
|
|
def _run_example(path: str) -> subprocess.CompletedProcess[str]:
|
|
env = os.environ.copy()
|
|
_ = env.pop("OPENAI_API_KEY", None)
|
|
|
|
return subprocess.run(
|
|
[sys.executable, path],
|
|
cwd=PROJECT_ROOT,
|
|
env=env,
|
|
text=True,
|
|
capture_output=True,
|
|
check=False,
|
|
)
|
|
|
|
|
|
def test_agenton_basics_example_smoke() -> None:
|
|
result = _run_example("examples/agenton/basics.py")
|
|
|
|
assert result.returncode == 0, result.stderr
|
|
assert "Prompts:" in result.stdout
|
|
assert "User prompts:" in result.stdout
|
|
assert "Tools:" in result.stdout
|
|
assert "Lifecycle: ['create', 'suspend', 'resume', 'delete']" in result.stdout
|
|
|
|
|
|
def test_agenton_pydantic_ai_example_smoke() -> None:
|
|
result = _run_example("examples/agenton/pydantic_ai_bridge.py")
|
|
|
|
assert result.returncode == 0, result.stderr
|
|
assert "SystemPromptPart: Prefer concrete details." in result.stdout
|
|
assert "UserPromptPart: [\"Use the tools for 'layer composition'.\"]" in result.stdout
|
|
assert "ToolCallPart: count_words(" in result.stdout
|
|
assert "ToolCallPart: write_tagline(" in result.stdout
|
|
assert "TextPart:" in result.stdout
|
|
|
|
|
|
def test_agenton_session_snapshot_example_smoke() -> None:
|
|
result = _run_example("examples/agenton/session_snapshot.py")
|
|
|
|
assert result.returncode == 0, result.stderr
|
|
assert "Snapshot:" in result.stdout
|
|
assert "Rehydrated handle: restored:demo-connection" in result.stdout
|