elijahbenizzy commented on code in PR #590:
URL: https://github.com/apache/burr/pull/590#discussion_r2464351768
##########
tests/core/test_application.py:
##########
@@ -486,6 +486,52 @@ def test__run_reducer_deletes_state():
assert "count" not in state
+def test__validate_reducer_writes_with_state_keys_returning_list():
+ """Tests that _validate_reducer_writes works when state.keys() returns a
list.
+
+ This is a regression test for a bug where state.keys() could return a list
+ instead of a set, causing a TypeError when trying to do set subtraction.
+ """
+ from burr.core.application import _validate_reducer_writes
Review Comment:
Inline import?
##########
tests/integrations/test_burr_opentelemetry.py:
##########
@@ -43,3 +48,137 @@ class SampleModel(pydantic.BaseModel):
)
def test_convert_to_otel_attribute(value, expected):
assert convert_to_otel_attribute(value) == expected
+
+
+def test_burr_tracking_span_processor_on_start_with_none_tracker():
+ """Test that on_start handles None tracker gracefully without raising an
error."""
+ processor = BurrTrackingSpanProcessor()
+
+ # Mock a span with a parent
+ mock_span = Mock()
+ mock_span.parent = Mock()
+ mock_span.parent.span_id = 12345
+ mock_span.name = "test_span"
+
+ # Mock the get_cached_span to return a parent span context
+ with patch("burr.integrations.opentelemetry.get_cached_span") as
mock_get_cached:
+ mock_parent_context = Mock()
+ mock_parent_context.action_span = Mock()
+ mock_parent_context.action_span.spawn = Mock(return_value=Mock())
+ mock_parent_context.partition_key = "test_partition"
+ mock_parent_context.app_id = "test_app"
+ mock_get_cached.return_value = mock_parent_context
+
+ # Mock cache_span
+ with patch("burr.integrations.opentelemetry.cache_span"):
+ # Set tracker_context to None (simulating no tracker in context)
+ token = tracker_context.set(None)
+ try:
+ # This should not raise an error even though tracker is None
+ processor.on_start(mock_span, parent_context=None)
+ finally:
+ tracker_context.reset(token)
+
+
+def test_burr_tracking_span_processor_on_end_with_none_tracker():
+ """Test that on_end handles None tracker gracefully without raising an
error."""
+ processor = BurrTrackingSpanProcessor()
Review Comment:
Are we sure we need all this mocking? IIRC I wrote this to be easier to unit
test...
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]