Skip to content

Commit

Permalink
Address feedback + test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
corps committed Jul 20, 2023
1 parent 07a6744 commit fe9bc12
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 15 deletions.
4 changes: 2 additions & 2 deletions src/sentry/integrations/pagerduty/actions/form.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ def _validate_service(self, service_id: int, integration_id: int) -> None:
"service": dict(self.fields["service"].choices).get(service_id),
}

ois = integration_service.get_organization_integrations(
org_integrations = integration_service.get_organization_integrations(
integration_id=integration_id,
providers=[ExternalProviders.PAGERDUTY.name],
)

if not any(
pds
for oi in ois
for oi in org_integrations
for pds in oi.config.get("pagerduty_services", [])
if pds["id"] == service_id
):
Expand Down
2 changes: 0 additions & 2 deletions src/sentry/models/integrations/pagerduty_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,10 @@
class PagerDutyService(DefaultFieldsModel):
__include_in_export__ = False

# organization_integration_id = HybridCloudForeignKey(
organization_integration = FlexibleForeignKey(
"sentry.OrganizationIntegration", on_delete=CASCADE, db_constraint=False
)

# organization_id = BoundedBigIntegerField(db_index=True)
organization_id = HybridCloudForeignKey("sentry.Organization", on_delete="cascade")

# From a region point of view, you really only have per organization scoping.
Expand Down
3 changes: 0 additions & 3 deletions src/sentry/services/hybrid_cloud/integration/serial.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ def serialize_integration(integration: Integration) -> RpcIntegration:


def serialize_organization_integration(oi: OrganizationIntegration) -> RpcOrganizationIntegration:
# if oi.integration
# i for i in integrations if i.provider == ExternalProviders.PAGERDUTY.name
# if
config: Dict[str, Any] = dict(**oi.config)
if oi.integration.provider == ExternalProviders.PAGERDUTY.name:
config["pagerduty_services"] = [
Expand Down
4 changes: 3 additions & 1 deletion tests/sentry/db/test_silo_models.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
from sentry.api.serializers.base import registry
from sentry.models import OrganizationIntegration, PagerDutyService
from sentry.testutils.silo import (
validate_models_have_silos,
validate_no_cross_silo_deletions,
validate_no_cross_silo_foreign_keys,
)

decorator_exemptions = set()
fk_exemptions = set()
# Temporary, remove after finishing changes on getsentry side
fk_exemptions = {(PagerDutyService, OrganizationIntegration)}


def test_models_have_silos():
Expand Down
15 changes: 8 additions & 7 deletions tests/sentry/integrations/pagerduty/test_notify_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,14 @@ class PagerDutyNotifyActionTest(RuleTestCase, PerformanceIssueTestCase):
rule_cls = PagerDutyNotifyServiceAction

def setUp(self):
self.integration = Integration.objects.create(
provider="pagerduty",
name="Example",
external_id=EXTERNAL_ID,
metadata={"services": SERVICES},
)
self.integration.add_organization(self.organization, self.user)
with assume_test_silo_mode(SiloMode.CONTROL):
self.integration = Integration.objects.create(
provider="pagerduty",
name="Example",
external_id=EXTERNAL_ID,
metadata={"services": SERVICES},
)
self.integration.add_organization(self.organization, self.user)
self.service = PagerDutyService.objects.create(
service_name=SERVICES[0]["service_name"],
integration_key=SERVICES[0]["integration_key"],
Expand Down

0 comments on commit fe9bc12

Please sign in to comment.