mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-05-23 08:25:57 +00:00
fix(storage): address repository review feedback
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from types import SimpleNamespace
|
||||
|
||||
@@ -62,6 +64,30 @@ def test_database_postgres_config_preserves_url_and_pool_options():
|
||||
assert url.database == "deerflow"
|
||||
|
||||
|
||||
def test_mysql_database_url_is_normalized_to_async_driver():
|
||||
storage = StorageConfig(
|
||||
driver="mysql",
|
||||
database_url="mysql://user:pass@db.example:3306/deerflow",
|
||||
)
|
||||
|
||||
url = _create_database_url(storage)
|
||||
|
||||
assert url.drivername == "mysql+aiomysql"
|
||||
assert url.database == "deerflow"
|
||||
|
||||
|
||||
def test_mysql_async_database_url_is_preserved():
|
||||
storage = StorageConfig(
|
||||
driver="mysql",
|
||||
database_url="mysql+asyncmy://user:pass@db.example:3306/deerflow",
|
||||
)
|
||||
|
||||
url = _create_database_url(storage)
|
||||
|
||||
assert url.drivername == "mysql+asyncmy"
|
||||
assert url.database == "deerflow"
|
||||
|
||||
|
||||
def test_database_postgres_requires_url():
|
||||
database = SimpleNamespace(backend="postgres", postgres_url="")
|
||||
|
||||
@@ -74,3 +100,25 @@ def test_unsupported_database_backend_rejected():
|
||||
|
||||
with pytest.raises(ValueError, match="Unsupported database backend"):
|
||||
storage_config_from_database_config(database)
|
||||
|
||||
|
||||
def test_storage_models_import_without_config_file(tmp_path):
|
||||
env = os.environ.copy()
|
||||
env["DEER_FLOW_CONFIG_PATH"] = str(tmp_path / "missing-config.yaml")
|
||||
|
||||
result = subprocess.run(
|
||||
[
|
||||
sys.executable,
|
||||
"-c",
|
||||
"from store.persistence.base_model import UniversalText, id_key; "
|
||||
"from store.repositories.models import RunEvent; "
|
||||
"print(UniversalText.__name__, RunEvent.__tablename__, id_key)",
|
||||
],
|
||||
check=False,
|
||||
capture_output=True,
|
||||
env=env,
|
||||
text=True,
|
||||
)
|
||||
|
||||
assert result.returncode == 0, result.stderr
|
||||
assert "UniversalText run_events" in result.stdout
|
||||
|
||||
Reference in New Issue
Block a user