Let people name accounts and use the names to tell accounts apart

Connections get an account_name (migration 0039) that the owner sets with
PATCH /api/connections/<id>; the account label stays the account's
identity, so signing in again still finds it. When someone has more than
one account of a service, its tools are listed as "Telegram · <account>"
and the model sees each account's actions under the account's name
(telegram_send_message_alerts_bot) with the account in the description,
instead of _1 and _2. Actions shared by different services are named
after the service. Tools a user renamed keep their name.
This commit is contained in:
arc53-machine committed 2026-09-29 10:41:54 +01:00
1 parent 607c2296e3
commit bdcb88866a
11 files changed
+371 -7

No files matched your search

+50
View File
@@ -0,0 +1,50 @@
"""Migration round-trip test for 0039_connection_account_name."""
from __future__ import annotations
import os
import subprocess
import sys
from pathlib import Path
import pytest
from sqlalchemy import text
pytestmark = pytest.mark.integration
_0039 = "0039_connection_account_name"
_0038 = "0038_connections"
def _run_alembic(url: str, *args: str) -> None:
ini = Path(__file__).resolve().parents[3] / "docsgpt" / "alembic.ini"
subprocess.check_call(
[sys.executable, "-m", "alembic", "-c", str(ini), *args],
timeout=120,
env={**os.environ, "POSTGRES_URI": url},
)
def _has_column(conn) -> bool:
return conn.execute(
text(
"SELECT 1 FROM information_schema.columns WHERE table_schema = 'public' "
"AND table_name = 'connector_sessions' AND column_name = 'account_name'"
)
).fetchone() is not None
class TestMigration0039RoundTrip:
def test_head_has_account_name(self, pg_engine):
with pg_engine.connect() as conn:
assert _has_column(conn)
def test_downgrade_drops_then_upgrade_restores(self, pg_engine):
url = pg_engine.url.render_as_string(hide_password=False)
_run_alembic(url, "downgrade", _0038)
with pg_engine.connect() as conn:
assert not _has_column(conn)
_run_alembic(url, "upgrade", "head")
with pg_engine.connect() as conn:
assert _has_column(conn)