Skip to content

Commit 4006973

Browse files
committed
Making sure test coverage stays up
1 parent 1eef151 commit 4006973

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

arango/database.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2725,7 +2725,7 @@ def __init__(self, connection: Connection, max_queue_time_seconds: float) -> Non
27252725
executor=QueueBoundedApiExecutor(connection, max_queue_time_seconds),
27262726
)
27272727

2728-
def __repr__(self) -> str:
2728+
def __repr__(self) -> str: # pragma: no cover
27292729
return f"<QueueBoundedDatabase {self.name}>"
27302730

27312731
@property
@@ -2737,6 +2737,15 @@ def last_queue_time(self) -> float:
27372737
"""
27382738
return self._executor.queue_time_seconds
27392739

2740+
@property
2741+
def max_queue_time(self) -> float:
2742+
"""Return the maximum server-side queuing time in seconds.
2743+
2744+
:return: Maximum server-side queuing time in seconds.
2745+
:rtype: float
2746+
"""
2747+
return self._executor.max_queue_time_seconds
2748+
27402749
def adjust_max_queue_time(self, max_queue_time_seconds: float) -> None:
27412750
"""Adjust the maximum server-side queuing time in seconds.
27422751

arango/executor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ def __init__(self, connection: Connection, max_queue_time_seconds: float) -> Non
450450
self._queue_time_seconds = 0.0
451451

452452
@property
453-
def context(self) -> str:
453+
def context(self) -> str: # pragma: no cover
454454
return "queue-bounded"
455455

456456
@property

tests/test_queue_bounded.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,27 @@ def flood_with_requests(bounded_db, async_db):
1010
We can only try and make it as large as possible. However, if the system
1111
is fast enough, it may still be 0.
1212
"""
13+
bounded_db.aql.execute("RETURN SLEEP(0.5)", count=True)
1314
for _ in range(3):
1415
for _ in range(500):
1516
async_db.aql.execute("RETURN SLEEP(0.5)", count=True)
16-
for _ in range(3):
17-
bounded_db.aql.execute("RETURN SLEEP(0.5)", count=True)
17+
bounded_db.aql.execute("RETURN SLEEP(0.5)", count=True)
1818
if bounded_db.last_queue_time >= 0:
1919
break
2020

2121

2222
def test_queue_bounded(db):
2323
bounded_db = db.begin_queue_bounded_execution(100)
24+
assert bounded_db.max_queue_time == 100
25+
2426
async_db = db.begin_async_execution(return_result=True)
2527

2628
flood_with_requests(bounded_db, async_db)
2729
assert bounded_db.last_queue_time >= 0
2830

2931
# We can only emit a warning here. The test will still pass.
3032
if bounded_db.last_queue_time == 0:
31-
warnings.warn("last_queue_time is 0, test may be unreliable")
33+
warnings.warn(f"last_queue_time of {bounded_db} is 0, test may be unreliable")
3234

3335
bounded_db.adjust_max_queue_time(0.0001)
3436
try:
@@ -39,5 +41,6 @@ def test_queue_bounded(db):
3941
assert e.error_code == 21004
4042
else:
4143
warnings.warn(
42-
f"last queue time is {bounded_db.last_queue_time}, test may be unreliable"
44+
f"last_queue_time of {bounded_db} is {bounded_db.last_queue_time},"
45+
f"test may be unreliable"
4346
)

0 commit comments

Comments
 (0)