1
1
from sentry .sentry_apps .logic import consolidate_events , expand_events
2
2
from sentry .sentry_apps .models .servicehook import ServiceHook
3
3
from sentry .sentry_apps .services .hook import RpcServiceHook , hook_service
4
+ from sentry .sentry_apps .services .hook .model import RpcInstallationOrganizationPair
4
5
from sentry .sentry_apps .utils .webhooks import EVENT_EXPANSION , SentryAppResourceType
5
6
from sentry .silo .base import SiloMode
6
7
from sentry .testutils .cases import TestCase
@@ -355,8 +356,12 @@ def test_bulk_create_service_hooks_for_app_success(self) -> None:
355
356
356
357
# Prepare installation-organization pairs
357
358
installation_org_pairs = [
358
- (installation1 .id , self .org .id ),
359
- (installation2 .id , org2 .id ),
359
+ RpcInstallationOrganizationPair (
360
+ installation_id = installation1 .id , organization_id = self .org .id
361
+ ),
362
+ RpcInstallationOrganizationPair (
363
+ installation_id = installation2 .id , organization_id = org2 .id
364
+ ),
360
365
]
361
366
362
367
result = hook_service .bulk_create_service_hooks_for_app (
@@ -402,7 +407,11 @@ def test_bulk_create_service_hooks_for_app_with_event_expansion(self) -> None:
402
407
region_name = "us" ,
403
408
application_id = self .sentry_app .application .id ,
404
409
events = ["issue" , "comment" ], # These should expand
405
- installation_organization_ids = [(installation .id , self .org .id )],
410
+ installation_organization_ids = [
411
+ RpcInstallationOrganizationPair (
412
+ installation_id = installation .id , organization_id = self .org .id
413
+ )
414
+ ],
406
415
url = "https://example.com/webhook" ,
407
416
)
408
417
@@ -454,7 +463,11 @@ def test_bulk_create_service_hooks_for_app_ignore_conflicts(self) -> None:
454
463
region_name = "us" ,
455
464
application_id = self .sentry_app .application .id ,
456
465
events = ["error.created" ],
457
- installation_organization_ids = [(installation .id , self .org .id )],
466
+ installation_organization_ids = [
467
+ RpcInstallationOrganizationPair (
468
+ installation_id = installation .id , organization_id = self .org .id
469
+ )
470
+ ],
458
471
url = "https://different-url.com/webhook" ,
459
472
)
460
473
@@ -483,12 +496,16 @@ def test_bulk_create_service_hooks_for_app_large_batch(self) -> None:
483
496
installation = self .create_sentry_app_installation (
484
497
slug = self .sentry_app .slug , organization = org , user = self .user
485
498
)
486
- installation_org_pairs .append ((installation .id , org .id ))
499
+ installation_org_pairs .append (
500
+ RpcInstallationOrganizationPair (
501
+ installation_id = installation .id , organization_id = org .id
502
+ )
503
+ )
487
504
488
505
# Delete existing hooks to test clean bulk creation
489
506
with assume_test_silo_mode (SiloMode .REGION ):
490
507
ServiceHook .objects .filter (
491
- installation_id__in = [pair [ 0 ] for pair in installation_org_pairs ]
508
+ installation_id__in = [pair . installation_id for pair in installation_org_pairs ]
492
509
).delete ()
493
510
494
511
# Call bulk create
@@ -505,7 +522,9 @@ def test_bulk_create_service_hooks_for_app_large_batch(self) -> None:
505
522
506
523
# Verify all hooks were created correctly
507
524
with assume_test_silo_mode (SiloMode .REGION ):
508
- for installation_id , org_id in installation_org_pairs :
525
+ for pair in installation_org_pairs :
526
+ installation_id = pair .installation_id
527
+ org_id = pair .organization_id
509
528
hook = ServiceHook .objects .get (
510
529
installation_id = installation_id , application_id = self .sentry_app .application .id
511
530
)
0 commit comments