Skip to content

Commit

Permalink
add test first pass
Browse files Browse the repository at this point in the history
  • Loading branch information
victoria-yining-huang committed Nov 5, 2024
1 parent e21b7bc commit b63ca40
Showing 1 changed file with 54 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,60 @@ def test_transactions_spawn_save_event_transaction(
project_id=project_id,
)

from unittest.mock import patch
from sentry.utils import event_tracker

@patch('event_tracker.is_tracked', return_value=True)
@django_db_all
def test_transactions_tracks_save_event_transaction(
default_project,
task_runner,
preprocess_event,
save_event_transaction,
):
project_id = default_project.id
now = datetime.datetime.now()
event = {
"type": "transaction",
"timestamp": now.isoformat(),
"start_timestamp": now.isoformat(),
"spans": [],
"contexts": {
"trace": {
"parent_span_id": "8988cec7cc0779c1",
"type": "trace",
"op": "foobar",
"trace_id": "a7d67cf796774551a95be6543cacd459",
"span_id": "babaae0d4b7512d9",
"status": "ok",
}
},
}
payload = get_normalized_event(event, default_project)
event_id = payload["event_id"]
start_time = time.time() - 3600
process_event(
ConsumerType.Events,
{
"payload": orjson.dumps(payload).decode(),
"start_time": start_time,
"event_id": event_id,
"project_id": project_id,
"remote_addr": "127.0.0.1",
},
project=default_project,
)
assert save_event_transaction.delay.call_args[1]["is_tracked"] == True

# assert not len(preprocess_event)
# assert save_event_transaction.delay.call_args[0] == ()
# assert save_event_transaction.delay.call_args[1] == dict(
# cache_key=f"e:{event_id}:{project_id}",
# data=None,
# start_time=start_time,
# event_id=event_id,
# project_id=project_id,
# )

@django_db_all
def test_accountant_transaction(default_project):
Expand Down

0 comments on commit b63ca40

Please sign in to comment.