mirror of
https://github.com/tiennm99/DocsGPT.git
synced 2026-10-14 02:15:06 +00:00
Give a member the account they just connected
Member-mode resolution ranked accounts by last_used_at first, so a connection added by Connect to continue (never used) lost to any older used account. Accounts now rank by the later of last use and creation.
This commit is contained in:
1 parent
259da38f17
commit
23e7145cee
2 files changed
+21
-3
No files matched your search
@@ -104,6 +104,22 @@ class TestResolution:
|
||||
resolved = resolve_connection(_tool(owner, mode="member"), "bob")
|
||||
assert resolved.available and resolved.connection_id == newer
|
||||
|
||||
def test_member_gets_the_account_they_just_connected(self, pg_conn):
|
||||
from docsgpt.connectors.resolve import resolve_connection
|
||||
|
||||
owner = _connection(pg_conn)
|
||||
used = _connection(pg_conn, user="bob")
|
||||
pg_conn.execute(text(
|
||||
"UPDATE connector_sessions SET account_label = 'bob-work', created_at = now() - interval '30 days', "
|
||||
"updated_at = now() - interval '30 days', last_used_at = now() - interval '1 hour' "
|
||||
"WHERE id = CAST(:i AS uuid)"
|
||||
), {"i": used})
|
||||
# Added by "Connect to continue": never used yet.
|
||||
added = _connection(pg_conn, user="bob")
|
||||
with _service_db(pg_conn):
|
||||
resolved = resolve_connection(_tool(owner, mode="member"), "bob")
|
||||
assert resolved.available and resolved.connection_id == added
|
||||
|
||||
def test_member_mode_without_own_connection_is_unavailable(self, pg_conn):
|
||||
from docsgpt.connectors.resolve import resolve_connection
|
||||
|
||||
|
||||
Reference in new issue
Block a user