Skip to content

Commit

Permalink
Fix: applied sentry_init_with_reset fixture
Browse files Browse the repository at this point in the history
  • Loading branch information
seyoon-lim committed Aug 10, 2024
1 parent 68aaed6 commit 6af8cd4
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions tests/integrations/spark/test_spark.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@
################


@pytest.fixture(scope="function")
def sentry_init_with_reset(sentry_init):
from sentry_sdk.integrations import _processed_integrations

yield lambda: sentry_init(integrations=[SparkIntegration()])
_processed_integrations.remove("spark")


@pytest.fixture(scope="function")
def create_spark_context():
yield lambda: SparkContext(appName="Testing123")
Expand Down Expand Up @@ -48,31 +56,26 @@ def test_start_sentry_listener(create_spark_context):
assert gateway._callback_server is not None


def test_initialize_spark_integration(sentry_init, create_spark_context):
sentry_init(integrations=[SparkIntegration()])
create_spark_context()


@patch("sentry_sdk.integrations.spark.spark_driver._activate_integration")
@patch("sentry_sdk.integrations.spark.spark_driver._patch_spark_context_init")
def test_initialize_spark_integration_before_spark_context_init(
mock_activate_integration,
sentry_init,
mock_patch_spark_context_init,
sentry_init_with_reset,
create_spark_context,
):
sentry_init(integrations=[SparkIntegration()])
sentry_init_with_reset()
create_spark_context()

mock_activate_integration.assert_called_once()
mock_patch_spark_context_init.assert_called_once()


@patch("sentry_sdk.integrations.spark.spark_driver._activate_integration")
def test_initialize_spark_integration_after_spark_context_init(
mock_activate_integration,
create_spark_context,
sentry_init,
sentry_init_with_reset,
):
create_spark_context()
sentry_init(integrations=[SparkIntegration()])
sentry_init_with_reset()

mock_activate_integration.assert_called_once()

Expand Down

0 comments on commit 6af8cd4

Please sign in to comment.