Skip to content

Commit c538e24

Browse files
committed
clarify tests some more
1 parent 68d2f9e commit c538e24

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

tests/test_ai_monitoring.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -211,32 +211,32 @@ def large_messages():
211211
class TestTruncateMessagesBySize:
212212
def test_no_truncation_needed(self, sample_messages):
213213
"""Test that messages under the limit are not truncated"""
214-
result, removed_count = truncate_messages_by_size(
214+
result, truncation_index = truncate_messages_by_size(
215215
sample_messages, max_bytes=MAX_GEN_AI_MESSAGE_BYTES
216216
)
217217
assert len(result) == len(sample_messages)
218218
assert result == sample_messages
219-
assert removed_count == 0
219+
assert truncation_index == 0
220220

221221
def test_truncation_removes_oldest_first(self, large_messages):
222222
"""Test that oldest messages are removed first during truncation"""
223223
small_limit = 3000
224-
result, removed_count = truncate_messages_by_size(
224+
result, truncation_index = truncate_messages_by_size(
225225
large_messages, max_bytes=small_limit
226226
)
227227
assert len(result) < len(large_messages)
228228

229229
if result:
230230
assert result[-1] == large_messages[-1]
231-
assert removed_count == len(large_messages) - len(result)
231+
assert truncation_index == len(large_messages) - len(result)
232232

233233
def test_empty_messages_list(self):
234234
"""Test handling of empty messages list"""
235-
result, removed_count = truncate_messages_by_size(
235+
result, truncation_index = truncate_messages_by_size(
236236
[], max_bytes=MAX_GEN_AI_MESSAGE_BYTES // 500
237237
)
238238
assert result == []
239-
assert removed_count == 0
239+
assert truncation_index == 0
240240

241241
def test_find_truncation_index(
242242
self,
@@ -329,7 +329,7 @@ def __init__(self):
329329
assert len(result) < len(large_messages)
330330
assert scope._gen_ai_original_message_count[span.span_id] == original_count
331331

332-
def test_scope_tracks_removed_messages(self, large_messages):
332+
def test_scope_tracks_original_message_count(self, large_messages):
333333
class MockSpan:
334334
def __init__(self):
335335
self.span_id = "test_span_id"
@@ -342,7 +342,7 @@ class MockScope:
342342
def __init__(self):
343343
self._gen_ai_original_message_count = {}
344344

345-
small_limit = 1000
345+
small_limit = 3000
346346
original_count = len(large_messages)
347347
span = MockSpan()
348348
scope = MockScope()
@@ -351,9 +351,8 @@ def __init__(self):
351351
large_messages, span, scope, max_bytes=small_limit
352352
)
353353

354-
n_removed = original_count - len(result)
355-
assert scope._gen_ai_original_message_count[span.span_id] == n_removed
356-
assert len(result) + n_removed == original_count
354+
assert scope._gen_ai_original_message_count[span.span_id] == original_count
355+
assert len(result) == 1
357356

358357
def test_empty_messages_returns_none(self):
359358
class MockSpan:
@@ -436,7 +435,7 @@ def __init__(self):
436435
# Simulate what client.py does
437436
event = {"spans": [{"span_id": span.span_id, "data": span.data.copy()}]}
438437

439-
# Mimic client.py logic - using scope to get the removed count
438+
# Mimic client.py logic - using scope to get the original length
440439
for event_span in event["spans"]:
441440
span_id = event_span.get("span_id")
442441
span_data = event_span.get("data", {})

0 commit comments

Comments
 (0)