(self)
| 1505 | signal.signal(signal.SIGALRM, old_signal_handler) |
| 1506 | |
| 1507 | def test_operation_failure(self): |
| 1508 | # Ensure MongoClient doesn't close socket after it gets an error |
| 1509 | # response to getLastError. PYTHON-395. We need a new client here |
| 1510 | # to avoid race conditions caused by replica set failover or idle |
| 1511 | # socket reaping. |
| 1512 | client = self.single_client() |
| 1513 | client.pymongo_test.test.find_one() |
| 1514 | pool = get_pool(client) |
| 1515 | socket_count = len(pool.conns) |
| 1516 | self.assertGreaterEqual(socket_count, 1) |
| 1517 | old_conn = next(iter(pool.conns)) |
| 1518 | client.pymongo_test.test.drop() |
| 1519 | client.pymongo_test.test.insert_one({"_id": "foo"}) |
| 1520 | with self.assertRaises(OperationFailure): |
| 1521 | client.pymongo_test.test.insert_one({"_id": "foo"}) |
| 1522 | |
| 1523 | self.assertEqual(socket_count, len(pool.conns)) |
| 1524 | new_con = next(iter(pool.conns)) |
| 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 |
nothing calls this directly
no test coverage detected