mirror of
https://github.com/MervinPraison/PraisonAIUI.git
synced 2026-11-10 11:41:34 -10:00
* feat: standardize bootstrap entrypoint to 'aiui run app.py' across examples Standardizes platform bootstrap patterns across examples per issue #71: - Update examples README table to use 'aiui run app.py' consistently - Update docstrings in examples 10, 12, 19-21 to show 'aiui run' instead of 'python app.py' - Remove fragmented bootstrap approaches (uvicorn.run, asyncio patterns) - Enforce single bootstrap SSOT as designed in CLI Co-authored-by: Mervin Praison <[email protected]> * feat: consolidate bootstrap entrypoints - auto-detect gateway apps (fixes #71) - Add bootstrap detection in CLI run command - Auto-detect gateway pattern (async main + AIUIGateway imports) - Auto-switch to praisonai backend for gateway apps - Delegate to user-defined main() when present - Remove sys.path hacks from example 14 - Update examples README to show unified aiui run entrypoint - Add BOOTSTRAP.md documentation for migration patterns Co-authored-by: Mervin Praison <[email protected]> * fix: resolve critical bootstrap entrypoint issues - Fix AST parsing bug in gateway auto-detection (cli.py:1419) - Revert background bots (email-bot, agentmail-bot) to python app.py - Revert custom UI apps (agent-dashboard) to python app.py - Update README.md to reflect correct run commands - Fix import formatting and remove unused imports These changes ensure that: 1. Gateway auto-detection works correctly by properly checking ast.alias.name 2. Background bots execute their __main__ blocks and don't start unnecessary web servers 3. Custom UI apps register their custom routes in __main__ blocks 4. Documentation matches actual working run commands 🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: Mervin Praison <[email protected]> --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Mervin Praison <[email protected]> Co-authored-by: Mervin Praison <[email protected]> Co-authored-by: Cursor <[email protected]>
60 lines
2.4 KiB
Python
60 lines
2.4 KiB
Python
"""Tests for AIUI_DATA_DIR environment variable support."""
|
|
import importlib
|
|
from pathlib import Path
|
|
|
|
|
|
class TestDataDir:
|
|
"""Tests for the _get_data_dir() function and AIUI_DATA_DIR env var."""
|
|
|
|
def test_default_data_dir(self, monkeypatch):
|
|
"""Default data dir is ~/.praisonaiui when env var is not set."""
|
|
monkeypatch.delenv("AIUI_DATA_DIR", raising=False)
|
|
# Need to reimport to pick up env change
|
|
import praisonaiui.server as server_module
|
|
importlib.reload(server_module)
|
|
d = server_module._get_data_dir()
|
|
assert ".praisonaiui" in str(d)
|
|
|
|
def test_custom_data_dir(self, monkeypatch, tmp_path):
|
|
"""AIUI_DATA_DIR overrides default data dir."""
|
|
custom = str(tmp_path / "custom_aiui")
|
|
monkeypatch.setenv("AIUI_DATA_DIR", custom)
|
|
# The function reads env at call time, so no reload needed
|
|
from praisonaiui.server import _get_data_dir
|
|
d = _get_data_dir()
|
|
assert str(d) == custom
|
|
|
|
def test_data_dir_created_if_missing(self, monkeypatch, tmp_path):
|
|
"""Data dir is created if it doesn't exist."""
|
|
custom = str(tmp_path / "nonexistent_dir")
|
|
assert not Path(custom).exists()
|
|
monkeypatch.setenv("AIUI_DATA_DIR", custom)
|
|
from praisonaiui.server import _get_data_dir
|
|
d = _get_data_dir()
|
|
# _get_data_dir creates the directory
|
|
assert Path(d).exists()
|
|
|
|
def test_config_store_uses_env_var(self, monkeypatch, tmp_path):
|
|
"""config_store._get_default_config_dir() respects AIUI_DATA_DIR."""
|
|
custom = str(tmp_path / "config_test")
|
|
monkeypatch.setenv("AIUI_DATA_DIR", custom)
|
|
from praisonaiui.config_store import _get_default_config_dir
|
|
d = _get_default_config_dir()
|
|
assert str(d) == custom
|
|
|
|
def test_env_var_read_at_call_time(self, monkeypatch, tmp_path):
|
|
"""Env var is read at function call time, not module import time."""
|
|
from praisonaiui.server import _get_data_dir
|
|
|
|
# First call with one value
|
|
dir1 = str(tmp_path / "dir1")
|
|
monkeypatch.setenv("AIUI_DATA_DIR", dir1)
|
|
result1 = _get_data_dir()
|
|
assert str(result1) == dir1
|
|
|
|
# Second call with different value
|
|
dir2 = str(tmp_path / "dir2")
|
|
monkeypatch.setenv("AIUI_DATA_DIR", dir2)
|
|
result2 = _get_data_dir()
|
|
assert str(result2) == dir2
|