From dc6660e497e908b5f19ee1740572736264908aaf Mon Sep 17 00:00:00 2001 From: Matt Hammerly Date: Wed, 30 Oct 2024 11:33:38 -0700 Subject: [PATCH] remove match from tests --- .../rust_tracing/test_rust_tracing.py | 32 ++++++++++--------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/tests/integrations/rust_tracing/test_rust_tracing.py b/tests/integrations/rust_tracing/test_rust_tracing.py index e4fa00f588..402b6a1207 100644 --- a/tests/integrations/rust_tracing/test_rust_tracing.py +++ b/tests/integrations/rust_tracing/test_rust_tracing.py @@ -162,16 +162,18 @@ def test_on_new_span_without_transaction(sentry_init, reset_integrations): def test_on_event_exception(sentry_init, reset_integrations, capture_events): - def event_type_mapping(metadata: dict) -> EventTypeMapping: - match RustTracingLevel(metadata.get("level")): - case RustTracingLevel.Error: - return EventTypeMapping.Exc - case RustTracingLevel.Warn | RustTracingLevel.Info: - return EventTypeMapping.Breadcrumb - case RustTracingLevel.Debug: - return EventTypeMapping.Event - case RustTracingLevel.Trace: - return EventTypeMapping.Ignore + def event_type_mapping(metadata: dict[str, object]) -> EventTypeMapping: + level = RustTracingLevel(metadata.get("level")) + if level == RustTracingLevel.Error: + return EventTypeMapping.Exc + elif level in (RustTracingLevel.Warn, RustTracingLevel.Info): + return EventTypeMapping.Breadcrumb + elif level == RustTracingLevel.Debug: + return EventTypeMapping.Event + elif level == RustTracingLevel.Trace: + return EventTypeMapping.Ignore + else: + return EventTypeMapping.Ignore rust_tracing = FakeRustTracing() integration = RustTracingIntegration( @@ -207,7 +209,7 @@ def event_type_mapping(metadata: dict) -> EventTypeMapping: def test_on_event_breadcrumb(sentry_init, reset_integrations, capture_events): - def event_type_mapping(metadata: dict) -> EventTypeMapping: + def event_type_mapping(metadata: dict[str, object]) -> EventTypeMapping: match RustTracingLevel(metadata.get("level")): case RustTracingLevel.Error: return EventTypeMapping.Exc @@ -247,7 +249,7 @@ def event_type_mapping(metadata: dict) -> EventTypeMapping: def test_on_event_event(sentry_init, reset_integrations, capture_events): - def event_type_mapping(metadata: dict) -> EventTypeMapping: + def event_type_mapping(metadata: dict[str, object]) -> EventTypeMapping: match RustTracingLevel(metadata.get("level")): case RustTracingLevel.Error: return EventTypeMapping.Exc @@ -293,7 +295,7 @@ def event_type_mapping(metadata: dict) -> EventTypeMapping: def test_on_event_ignored(sentry_init, reset_integrations, capture_events): - def event_type_mapping(metadata: dict) -> EventTypeMapping: + def event_type_mapping(metadata: dict[str, object]) -> EventTypeMapping: match RustTracingLevel(metadata.get("level")): case RustTracingLevel.Error: return EventTypeMapping.Exc @@ -328,7 +330,7 @@ def event_type_mapping(metadata: dict) -> EventTypeMapping: def test_span_filter(sentry_init, reset_integrations, capture_events): - def span_filter(metadata: dict) -> bool: + def span_filter(metadata: dict[str, object]) -> bool: return RustTracingLevel(metadata.get("level")) in ( RustTracingLevel.Error, RustTracingLevel.Warn, @@ -385,7 +387,7 @@ def test_record(sentry_init, reset_integrations): def test_record_in_ignored_span(sentry_init, reset_integrations): - def span_filter(metadata: dict) -> bool: + def span_filter(metadata: dict[str, object]) -> bool: # Just ignore Trace return RustTracingLevel(metadata.get("level")) != RustTracingLevel.Trace