MCPcopy Create free account
hub / github.com/mongodb/mongo-python-driver / test_lazy_connect_w0

Method test_lazy_connect_w0

test/test_client.py:1527–1558  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1525 self.assertEqual(old_conn, new_con)
1526
1527 def test_lazy_connect_w0(self):
1528 # Ensure that connect-on-demand works when the first operation is
1529 # an unacknowledged write. This exercises _writable_max_wire_version().
1530
1531 # Use a separate collection to avoid races where we're still
1532 # completing an operation on a collection while the next test begins.
1533 client_context.client.drop_database("test_lazy_connect_w0")
1534 self.addCleanup(client_context.client.drop_database, "test_lazy_connect_w0")
1535
1536 client = self.rs_or_single_client(connect=False, w=0)
1537 client.test_lazy_connect_w0.test.insert_one({})
1538
1539 def predicate():
1540 return client.test_lazy_connect_w0.test.count_documents({}) == 1
1541
1542 wait_until(predicate, "find one document")
1543
1544 client = self.rs_or_single_client(connect=False, w=0)
1545 client.test_lazy_connect_w0.test.update_one({}, {"$set": {"x": 1}})
1546
1547 def predicate():
1548 return (client.test_lazy_connect_w0.test.find_one()).get("x") == 1
1549
1550 wait_until(predicate, "update one document")
1551
1552 client = self.rs_or_single_client(connect=False, w=0)
1553 client.test_lazy_connect_w0.test.delete_one({})
1554
1555 def predicate():
1556 return client.test_lazy_connect_w0.test.count_documents({}) == 0
1557
1558 wait_until(predicate, "delete one document")
1559
1560 @client_context.require_no_mongos
1561 def test_exhaust_network_error(self):

Callers

nothing calls this directly

Calls 7

wait_untilFunction · 0.90
addCleanupMethod · 0.80
rs_or_single_clientMethod · 0.80
drop_databaseMethod · 0.45
insert_oneMethod · 0.45
update_oneMethod · 0.45
delete_oneMethod · 0.45

Tested by

no test coverage detected