From 2144fc0811b86814cad3afa5e47806ee621a7d6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E9=A3=9E?= Date: Fri, 20 Sep 2024 11:33:02 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A8=A1=E6=8B=9F=20MongoDB=20aggregate=20?= =?UTF-8?q?=E7=9A=84=E6=B8=B8=E6=A0=87=E8=A1=8C=E4=B8=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/engines/tests.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/sql/engines/tests.py b/sql/engines/tests.py index eefb00ae0d..cc2073b37b 100644 --- a/sql/engines/tests.py +++ b/sql/engines/tests.py @@ -1843,13 +1843,20 @@ def test_current_op(self, mock_get_connection): # 模拟 MongoDB aggregate 的游标行为 class AggregateCursor: def __enter__(self): - yield {"client": "single_client", "effectiveUsers": [{"user": "user_1"}], "clientMetadata": {"mongos": {"client": "sharding_client"}}} - yield {"clientMetadata": {"mongos": {}}, "effectiveUsers": [{"user": "user_2"}]} + yield { + "client": "single_client", + "effectiveUsers": [{"user": "user_1"}], + "clientMetadata": {"mongos": {"client": "sharding_client"}}, + } + yield { + "clientMetadata": {"mongos": {}}, + "effectiveUsers": [{"user": "user_2"}], + } yield {"effectiveUsers": []} def __exit__(self, exc_type, exc_value, traceback): pass - + mock_conn = Mock() mock_conn.admin.aggregate.return_value = AggregateCursor() mock_get_connection.return_value = mock_conn