fix: clean up stale test references to removed attributes
This commit is contained in:
@@ -38,16 +38,6 @@ class TestShouldCompress:
|
|||||||
assert compressor.should_compress(prompt_tokens=50000) is False
|
assert compressor.should_compress(prompt_tokens=50000) is False
|
||||||
|
|
||||||
|
|
||||||
class TestShouldCompressPreflight:
|
|
||||||
def test_short_messages(self, compressor):
|
|
||||||
msgs = [{"role": "user", "content": "short"}]
|
|
||||||
assert compressor.should_compress_preflight(msgs) is False
|
|
||||||
|
|
||||||
def test_long_messages(self, compressor):
|
|
||||||
# Each message ~100k chars / 4 = 25k tokens, need >85k threshold
|
|
||||||
msgs = [{"role": "user", "content": "x" * 400000}]
|
|
||||||
assert compressor.should_compress_preflight(msgs) is True
|
|
||||||
|
|
||||||
|
|
||||||
class TestUpdateFromResponse:
|
class TestUpdateFromResponse:
|
||||||
def test_updates_fields(self, compressor):
|
def test_updates_fields(self, compressor):
|
||||||
@@ -58,27 +48,12 @@ class TestUpdateFromResponse:
|
|||||||
})
|
})
|
||||||
assert compressor.last_prompt_tokens == 5000
|
assert compressor.last_prompt_tokens == 5000
|
||||||
assert compressor.last_completion_tokens == 1000
|
assert compressor.last_completion_tokens == 1000
|
||||||
assert compressor.last_total_tokens == 6000
|
|
||||||
|
|
||||||
def test_missing_fields_default_zero(self, compressor):
|
def test_missing_fields_default_zero(self, compressor):
|
||||||
compressor.update_from_response({})
|
compressor.update_from_response({})
|
||||||
assert compressor.last_prompt_tokens == 0
|
assert compressor.last_prompt_tokens == 0
|
||||||
|
|
||||||
|
|
||||||
class TestGetStatus:
|
|
||||||
def test_returns_expected_keys(self, compressor):
|
|
||||||
status = compressor.get_status()
|
|
||||||
assert "last_prompt_tokens" in status
|
|
||||||
assert "threshold_tokens" in status
|
|
||||||
assert "context_length" in status
|
|
||||||
assert "usage_percent" in status
|
|
||||||
assert "compression_count" in status
|
|
||||||
|
|
||||||
def test_usage_percent_calculation(self, compressor):
|
|
||||||
compressor.last_prompt_tokens = 50000
|
|
||||||
status = compressor.get_status()
|
|
||||||
assert status["usage_percent"] == 50.0
|
|
||||||
|
|
||||||
|
|
||||||
class TestCompress:
|
class TestCompress:
|
||||||
def _make_messages(self, n):
|
def _make_messages(self, n):
|
||||||
|
|||||||
@@ -619,17 +619,14 @@ class TestReasoningDeltasFiredFlag(unittest.TestCase):
|
|||||||
agent = AIAgent.__new__(AIAgent)
|
agent = AIAgent.__new__(AIAgent)
|
||||||
agent.reasoning_callback = None
|
agent.reasoning_callback = None
|
||||||
agent.stream_delta_callback = None
|
agent.stream_delta_callback = None
|
||||||
agent._reasoning_deltas_fired = False
|
|
||||||
agent.verbose_logging = False
|
agent.verbose_logging = False
|
||||||
return agent
|
return agent
|
||||||
|
|
||||||
def test_fire_reasoning_delta_sets_flag(self):
|
def test_fire_reasoning_delta_calls_callback(self):
|
||||||
agent = self._make_agent()
|
agent = self._make_agent()
|
||||||
captured = []
|
captured = []
|
||||||
agent.reasoning_callback = lambda t: captured.append(t)
|
agent.reasoning_callback = lambda t: captured.append(t)
|
||||||
self.assertFalse(agent._reasoning_deltas_fired)
|
|
||||||
agent._fire_reasoning_delta("thinking...")
|
agent._fire_reasoning_delta("thinking...")
|
||||||
self.assertTrue(agent._reasoning_deltas_fired)
|
|
||||||
self.assertEqual(captured, ["thinking..."])
|
self.assertEqual(captured, ["thinking..."])
|
||||||
|
|
||||||
def test_build_assistant_message_skips_callback_when_already_streamed(self):
|
def test_build_assistant_message_skips_callback_when_already_streamed(self):
|
||||||
@@ -640,8 +637,7 @@ class TestReasoningDeltasFiredFlag(unittest.TestCase):
|
|||||||
agent.reasoning_callback = lambda t: captured.append(t)
|
agent.reasoning_callback = lambda t: captured.append(t)
|
||||||
agent.stream_delta_callback = lambda t: None # streaming is active
|
agent.stream_delta_callback = lambda t: None # streaming is active
|
||||||
|
|
||||||
# Simulate streaming having fired reasoning
|
# Simulate streaming having already fired reasoning
|
||||||
agent._reasoning_deltas_fired = True
|
|
||||||
|
|
||||||
msg = SimpleNamespace(
|
msg = SimpleNamespace(
|
||||||
content="I'll merge that.",
|
content="I'll merge that.",
|
||||||
@@ -665,9 +661,8 @@ class TestReasoningDeltasFiredFlag(unittest.TestCase):
|
|||||||
agent.reasoning_callback = lambda t: captured.append(t)
|
agent.reasoning_callback = lambda t: captured.append(t)
|
||||||
agent.stream_delta_callback = lambda t: None # streaming active
|
agent.stream_delta_callback = lambda t: None # streaming active
|
||||||
|
|
||||||
# Even though _reasoning_deltas_fired is False (reasoning came through
|
# Reasoning came through content tags, not reasoning_content deltas.
|
||||||
# content tags, not reasoning_content deltas), callback should not fire
|
# Callback should not fire since streaming is active.
|
||||||
agent._reasoning_deltas_fired = False
|
|
||||||
|
|
||||||
msg = SimpleNamespace(
|
msg = SimpleNamespace(
|
||||||
content="I'll merge that.",
|
content="I'll merge that.",
|
||||||
@@ -689,7 +684,6 @@ class TestReasoningDeltasFiredFlag(unittest.TestCase):
|
|||||||
agent.reasoning_callback = lambda t: captured.append(t)
|
agent.reasoning_callback = lambda t: captured.append(t)
|
||||||
# No streaming
|
# No streaming
|
||||||
agent.stream_delta_callback = None
|
agent.stream_delta_callback = None
|
||||||
agent._reasoning_deltas_fired = False
|
|
||||||
|
|
||||||
msg = SimpleNamespace(
|
msg = SimpleNamespace(
|
||||||
content="I'll merge that.",
|
content="I'll merge that.",
|
||||||
|
|||||||
Reference in New Issue
Block a user