Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 10 additions & 12 deletions tests/integrations/django/test_db_query_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,17 +346,16 @@ def test_no_query_source_if_duration_too_short(sentry_init, client, capture_even

class fake_record_sql_queries: # noqa: N801
def __init__(self, *args, **kwargs):
with record_sql_queries(*args, **kwargs) as span:
self.span = span

self.span.start_timestamp = datetime(2024, 1, 1, microsecond=0)
self.span.timestamp = datetime(2024, 1, 1, microsecond=99999)
self._ctx_mgr = record_sql_queries(*args, **kwargs)

def __enter__(self):
self.span = self._ctx_mgr.__enter__()
self.span.start_timestamp = datetime(2024, 1, 1, microsecond=0)
return self.span

def __exit__(self, type, value, traceback):
pass
self._ctx_mgr.__exit__(type, value, traceback)
self.span.timestamp = datetime(2024, 1, 1, microsecond=99999)

with mock.patch(
"sentry_sdk.integrations.django.record_sql_queries",
Expand Down Expand Up @@ -404,17 +403,16 @@ def test_query_source_if_duration_over_threshold(sentry_init, client, capture_ev

class fake_record_sql_queries: # noqa: N801
def __init__(self, *args, **kwargs):
with record_sql_queries(*args, **kwargs) as span:
self.span = span

self.span.start_timestamp = datetime(2024, 1, 1, microsecond=0)
self.span.timestamp = datetime(2024, 1, 1, microsecond=101000)
self._ctx_mgr = record_sql_queries(*args, **kwargs)

def __enter__(self):
self.span = self._ctx_mgr.__enter__()
self.span.start_timestamp = datetime(2024, 1, 1, microsecond=0)
return self.span

def __exit__(self, type, value, traceback):
pass
self._ctx_mgr.__exit__(type, value, traceback)
self.span.timestamp = datetime(2024, 1, 1, microsecond=101000)

with mock.patch(
"sentry_sdk.integrations.django.record_sql_queries",
Expand Down
52 changes: 19 additions & 33 deletions tests/integrations/sqlalchemy/test_sqlalchemy.py
Original file line number Diff line number Diff line change
Expand Up @@ -934,25 +934,19 @@ class Person(Base):

class fake_record_sql_queries: # noqa: N801
def __init__(self, *args, **kwargs):
with record_sql_queries_supporting_streaming(
self._ctx_mgr = record_sql_queries_supporting_streaming(
*args, **kwargs
) as span:
self.span = span

if span_streaming:
self.span._start_timestamp = datetime(2024, 1, 1, microsecond=0)
self.span._end_timestamp = datetime(
2024, 1, 1, microsecond=99999
)
else:
self.span.start_timestamp = datetime(2024, 1, 1, microsecond=0)
self.span.timestamp = datetime(2024, 1, 1, microsecond=99999)
)

def __enter__(self):
self.span = self._ctx_mgr.__enter__()
self.span._start_timestamp = datetime(2024, 1, 1, microsecond=0)
self.span._end_timestamp = datetime(2024, 1, 1, microsecond=99999)
return self.span

def __exit__(self, type, value, traceback):
pass
self.span._end_timestamp = None
self._ctx_mgr.__exit__(type, value, traceback)

with mock.patch(
"sentry_sdk.integrations.sqlalchemy.record_sql_queries_supporting_streaming",
Expand Down Expand Up @@ -1000,25 +994,18 @@ class Person(Base):

class fake_record_sql_queries: # noqa: N801
def __init__(self, *args, **kwargs):
with record_sql_queries_supporting_streaming(
self._ctx_mgr = record_sql_queries_supporting_streaming(
*args, **kwargs
) as span:
self.span = span

if span_streaming:
self.span._start_timestamp = datetime(2024, 1, 1, microsecond=0)
self.span._end_timestamp = datetime(
2024, 1, 1, microsecond=99999
)
else:
self.span.start_timestamp = datetime(2024, 1, 1, microsecond=0)
self.span.timestamp = datetime(2024, 1, 1, microsecond=99999)
)

def __enter__(self):
self.span = self._ctx_mgr.__enter__()
self.span.start_timestamp = datetime(2024, 1, 1, microsecond=0)
return self.span

def __exit__(self, type, value, traceback):
pass
self._ctx_mgr.__exit__(type, value, traceback)
self.span.timestamp = datetime(2024, 1, 1, microsecond=99999)

with mock.patch(
"sentry_sdk.integrations.sqlalchemy.record_sql_queries_supporting_streaming",
Expand Down Expand Up @@ -1159,19 +1146,18 @@ class Person(Base):

class fake_record_sql_queries: # noqa: N801
def __init__(self, *args, **kwargs):
with record_sql_queries_supporting_streaming(
self._ctx_mgr = record_sql_queries_supporting_streaming(
*args, **kwargs
) as span:
self.span = span

self.span.start_timestamp = datetime(2024, 1, 1, microsecond=0)
self.span.timestamp = datetime(2024, 1, 1, microsecond=101000)
)

def __enter__(self):
self.span = self._ctx_mgr.__enter__()
self.span.start_timestamp = datetime(2024, 1, 1, microsecond=0)
return self.span

def __exit__(self, type, value, traceback):
pass
self._ctx_mgr.__exit__(type, value, traceback)
self.span.timestamp = datetime(2024, 1, 1, microsecond=101000)

with mock.patch(
"sentry_sdk.integrations.sqlalchemy.record_sql_queries_supporting_streaming",
Expand Down
Loading