mirror of
https://gitcode.com/JianFeeeee/TrulyMEM-TrueHumanMEM.git
synced 2026-09-21 01:18:15 +00:00
70 lines
2.0 KiB
Python
70 lines
2.0 KiB
Python
import pytest
|
|
import os
|
|
import tempfile
|
|
|
|
os.environ["DEEPSEEK_API_KEY"] = "fake-test-key"
|
|
|
|
|
|
class TestUIImport:
|
|
def test_import_app(self):
|
|
from ui import GraphMemoryApp
|
|
assert GraphMemoryApp is not None
|
|
|
|
def test_import_config(self):
|
|
from ui import AppConfig
|
|
assert AppConfig is not None
|
|
|
|
|
|
class TestUIApp:
|
|
def test_create_app(self):
|
|
from ui import GraphMemoryApp
|
|
app = GraphMemoryApp()
|
|
assert app is not None
|
|
assert app._backend_server is None
|
|
assert app._backend_client is None
|
|
|
|
def test_create_app_with_config(self):
|
|
from ui import GraphMemoryApp, AppConfig
|
|
|
|
config = AppConfig(api_key="test-key", base_url="https://api.test.com")
|
|
app = GraphMemoryApp(config=config)
|
|
|
|
assert app._config is config
|
|
assert app._config.api_key == "test-key"
|
|
|
|
def test_create_app_with_backend(self):
|
|
from ui import GraphMemoryApp
|
|
from core import BackendServer
|
|
|
|
with tempfile.NamedTemporaryFile(suffix=".db", delete=False) as f:
|
|
db_path = f.name
|
|
|
|
try:
|
|
server = BackendServer(db_path=db_path, use_embedded_db=True)
|
|
server.start(api_key="", base_url="https://api.test.com")
|
|
|
|
app = GraphMemoryApp(backend_server=server)
|
|
|
|
assert app._backend_server is server
|
|
assert app._backend_client is not None
|
|
|
|
server.shutdown()
|
|
finally:
|
|
if os.path.exists(db_path):
|
|
os.unlink(db_path)
|
|
|
|
|
|
class TestAppConfig:
|
|
def test_config_from_env(self):
|
|
from ui import AppConfig
|
|
|
|
config = AppConfig.from_env()
|
|
assert config is not None
|
|
|
|
def test_config_default_values(self):
|
|
from ui import AppConfig
|
|
|
|
config = AppConfig()
|
|
assert config.api_key == ""
|
|
assert config.model == "deepseek-chat"
|
|
assert config.base_url == "https://api.deepseek.com" |