|
35 | 35 | RoutingConfig,
|
36 | 36 | WorkspaceConfig
|
37 | 37 | )
|
| 38 | +from neo4j._deadline import Deadline |
38 | 39 | from neo4j.exceptions import (
|
39 | 40 | ServiceUnavailable,
|
40 | 41 | SessionExpired
|
@@ -271,3 +272,29 @@ def test_failing_opener_leaves_connections_in_use_alone(opener):
|
271 | 272 | pool.acquire(READ_ACCESS, 30, 60, "test_db", None)
|
272 | 273 |
|
273 | 274 | assert not cx1.closed()
|
| 275 | + |
| 276 | + |
| 277 | +def test__acquire_new_later_with_room(opener): |
| 278 | + config = PoolConfig() |
| 279 | + config.max_connection_pool_size = 1 |
| 280 | + pool = Neo4jPool( |
| 281 | + opener, config, WorkspaceConfig(), ROUTER_ADDRESS |
| 282 | + ) |
| 283 | + assert pool.connections_reservations[READER_ADDRESS] == 0 |
| 284 | + creator = pool._acquire_new_later(READER_ADDRESS, Deadline(1)) |
| 285 | + assert pool.connections_reservations[READER_ADDRESS] == 1 |
| 286 | + assert callable(creator) |
| 287 | + |
| 288 | + |
| 289 | +def test__acquire_new_later_without_room(opener): |
| 290 | + config = PoolConfig() |
| 291 | + config.max_connection_pool_size = 1 |
| 292 | + pool = Neo4jPool( |
| 293 | + opener, config, WorkspaceConfig(), ROUTER_ADDRESS |
| 294 | + ) |
| 295 | + _ = pool.acquire(READ_ACCESS, 30, 60, "test_db", None) |
| 296 | + # pool is full now |
| 297 | + assert pool.connections_reservations[READER_ADDRESS] == 0 |
| 298 | + creator = pool._acquire_new_later(READER_ADDRESS, Deadline(1)) |
| 299 | + assert pool.connections_reservations[READER_ADDRESS] == 0 |
| 300 | + assert creator is None |
0 commit comments