Skip to content

Commit b38ee00

Browse files
committed
PYTHON-5166 Fix test to check for 8.0 for bulkWrite command support
1 parent 72e214a commit b38ee00

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

test/asynchronous/test_database.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -432,13 +432,14 @@ async def test_command_with_regex(self):
432432

433433
async def test_command_bulkWrite(self):
434434
# Ensure bulk write commands can be run directly via db.command().
435-
await self.client.admin.command(
436-
{
437-
"bulkWrite": 1,
438-
"nsInfo": [{"ns": self.db.test.full_name}],
439-
"ops": [{"insert": 0, "document": {}}],
440-
}
441-
)
435+
if async_client_context.version.at_least(8, 0):
436+
await self.client.admin.command(
437+
{
438+
"bulkWrite": 1,
439+
"nsInfo": [{"ns": self.db.test.full_name}],
440+
"ops": [{"insert": 0, "document": {}}],
441+
}
442+
)
442443
await self.db.command({"insert": "test", "documents": [{}]})
443444
await self.db.command({"update": "test", "updates": [{"q": {}, "u": {"$set": {"x": 1}}}]})
444445
await self.db.command({"delete": "test", "deletes": [{"q": {}, "limit": 1}]})

test/test_database.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -427,13 +427,14 @@ def test_command_with_regex(self):
427427

428428
def test_command_bulkWrite(self):
429429
# Ensure bulk write commands can be run directly via db.command().
430-
self.client.admin.command(
431-
{
432-
"bulkWrite": 1,
433-
"nsInfo": [{"ns": self.db.test.full_name}],
434-
"ops": [{"insert": 0, "document": {}}],
435-
}
436-
)
430+
if client_context.version.at_least(8, 0):
431+
self.client.admin.command(
432+
{
433+
"bulkWrite": 1,
434+
"nsInfo": [{"ns": self.db.test.full_name}],
435+
"ops": [{"insert": 0, "document": {}}],
436+
}
437+
)
437438
self.db.command({"insert": "test", "documents": [{}]})
438439
self.db.command({"update": "test", "updates": [{"q": {}, "u": {"$set": {"x": 1}}}]})
439440
self.db.command({"delete": "test", "deletes": [{"q": {}, "limit": 1}]})

0 commit comments

Comments
 (0)