Skip to content

Commit 265ef3b

Browse files
committed
make public
1 parent 9f9c9d8 commit 265ef3b

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

pymongo/asynchronous/mongo_client.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1041,7 +1041,10 @@ async def target() -> bool:
10411041
self._kill_cursors_executor = executor
10421042
self._opened = False
10431043

1044-
def _append_metadata(self, driver_info: DriverInfo) -> None:
1044+
def append_metadata(self, driver_info: DriverInfo) -> None:
1045+
"""
1046+
Appends the given metadata to existing driver metadata.
1047+
"""
10451048
metadata = self._options.pool_options.metadata
10461049
for k, v in driver_info._asdict().items():
10471050
if v is None:

pymongo/synchronous/mongo_client.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1041,7 +1041,10 @@ def target() -> bool:
10411041
self._kill_cursors_executor = executor
10421042
self._opened = False
10431043

1044-
def _append_metadata(self, driver_info: DriverInfo) -> None:
1044+
def append_metadata(self, driver_info: DriverInfo) -> None:
1045+
"""
1046+
Appends the given metadata to existing driver metadata.
1047+
"""
10451048
metadata = self._options.pool_options.metadata
10461049
for k, v in driver_info._asdict().items():
10471050
if v is None:

test/mockupdb/test_client_metadata.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def check_metadata_added(
8383
time.sleep(0.005)
8484

8585
# add new metadata
86-
client._append_metadata(DriverInfo(add_name, add_version, add_platform))
86+
client.append_metadata(DriverInfo(add_name, add_version, add_platform))
8787
new_name, new_version, new_platform, new_metadata = self.send_ping_and_get_metadata(
8888
client, True
8989
)
@@ -148,7 +148,7 @@ def test_multiple_successive_metadata_updates(self):
148148
client = MongoClient(
149149
"mongodb://" + self.server.address_string, maxIdleTimeMS=1, connect=False
150150
)
151-
client._append_metadata(DriverInfo("library", "1.2", "Library Platform"))
151+
client.append_metadata(DriverInfo("library", "1.2", "Library Platform"))
152152
self.check_metadata_added(client, "framework", "2.0", "Framework Platform")
153153
client.close()
154154

@@ -157,7 +157,7 @@ def test_multiple_successive_metadata_updates_platform_none(self):
157157
"mongodb://" + self.server.address_string,
158158
maxIdleTimeMS=1,
159159
)
160-
client._append_metadata(DriverInfo("library", "1.2", "Library Platform"))
160+
client.append_metadata(DriverInfo("library", "1.2", "Library Platform"))
161161
self.check_metadata_added(client, "framework", "2.0", None)
162162
client.close()
163163

@@ -166,7 +166,7 @@ def test_multiple_successive_metadata_updates_version_none(self):
166166
"mongodb://" + self.server.address_string,
167167
maxIdleTimeMS=1,
168168
)
169-
client._append_metadata(DriverInfo("library", "1.2", "Library Platform"))
169+
client.append_metadata(DriverInfo("library", "1.2", "Library Platform"))
170170
self.check_metadata_added(client, "framework", None, "Framework Platform")
171171
client.close()
172172

@@ -175,7 +175,7 @@ def test_multiple_successive_metadata_updates_platform_version_none(self):
175175
"mongodb://" + self.server.address_string,
176176
maxIdleTimeMS=1,
177177
)
178-
client._append_metadata(DriverInfo("library", "1.2", "Library Platform"))
178+
client.append_metadata(DriverInfo("library", "1.2", "Library Platform"))
179179
self.check_metadata_added(client, "framework", None, None)
180180
client.close()
181181

@@ -196,7 +196,7 @@ def test_doesnt_update_established_connections(self):
196196

197197
# add data
198198
add_name, add_version, add_platform = "framework", "2.0", "Framework Platform"
199-
client._append_metadata(DriverInfo(add_name, add_version, add_platform))
199+
client.append_metadata(DriverInfo(add_name, add_version, add_platform))
200200
# check new data isn't sent
201201
self.handshake_req: Optional[dict] = None
202202
client.admin.command("ping")

0 commit comments

Comments
 (0)