Skip to content

Commit

Permalink
fix sentry apps tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Christinarlong committed Dec 11, 2024
1 parent f6aaca7 commit d18f463
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/sentry/sentry_apps/alert_rule_action_creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
from django.utils.functional import cached_property

from sentry.coreapi import APIError
from sentry.exceptions import SentryAppIntegratorError
from sentry.sentry_apps.external_requests.alert_rule_action_requester import (
AlertRuleActionRequester,
AlertRuleActionResult,
)
from sentry.sentry_apps.models.sentry_app import SentryApp
from sentry.sentry_apps.models.sentry_app_component import SentryAppComponent
from sentry.sentry_apps.models.sentry_app_installation import SentryAppInstallation
from sentry.sentry_apps.utils.errors import SentryAppIntegratorError


@dataclass
Expand Down
7 changes: 2 additions & 5 deletions src/sentry/sentry_apps/installations.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
from sentry.sentry_apps.models.sentry_app_installation_token import SentryAppInstallationToken
from sentry.sentry_apps.services.hook import hook_service
from sentry.sentry_apps.tasks.sentry_apps import installation_webhook
from sentry.sentry_apps.utils.errors import SentryAppError
from sentry.users.models.user import User
from sentry.users.services.user.model import RpcUser
from sentry.utils import metrics
Expand Down Expand Up @@ -194,10 +193,8 @@ class SentryAppInstallationNotifier:

def run(self) -> None:
if self.action not in VALID_ACTIONS:
raise SentryAppError(
APIUnauthorized(
f"Invalid action '{self.action} for installation notifier for {self.sentry_app}"
)
raise APIUnauthorized(
f"Invalid action '{self.action} for installation notifier for {self.sentry_app}"
)

send_and_save_webhook_request(self.sentry_app, self.request)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import pytest
import responses

from sentry.coreapi import APIUnauthorized
from sentry.sentry_apps.external_issues.issue_link_creator import IssueLinkCreator
from sentry.sentry_apps.models.platformexternalissue import PlatformExternalIssue
from sentry.sentry_apps.services.app import app_service
from sentry.sentry_apps.utils.errors import SentryAppError
from sentry.testutils.cases import TestCase
from sentry.users.services.user.serial import serialize_rpc_user

Expand Down Expand Up @@ -60,7 +60,7 @@ def test_creates_external_issue(self):
assert external_issue.display_name == "Projectname#issue-1"

def test_invalid_action(self):
with pytest.raises(APIUnauthorized):
with pytest.raises(SentryAppError):
IssueLinkCreator(
install=self.install,
group=self.group,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import pytest
import responses
from jsonschema import ValidationError

from sentry.coreapi import APIError
from sentry.sentry_apps.external_requests.issue_link_requester import IssueLinkRequester
from sentry.sentry_apps.services.app import app_service
from sentry.sentry_apps.utils.errors import SentryAppIntegratorError
from sentry.testutils.cases import TestCase
from sentry.users.services.user.serial import serialize_rpc_user
from sentry.utils import json
Expand Down Expand Up @@ -95,7 +94,7 @@ def test_invalid_response_format(self):
status=200,
content_type="application/json",
)
with pytest.raises(ValidationError):
with pytest.raises(SentryAppIntegratorError):
IssueLinkRequester(
install=self.install,
group=self.group,
Expand All @@ -114,7 +113,7 @@ def test_500_response(self):
status=500,
)

with pytest.raises(APIError):
with pytest.raises(SentryAppIntegratorError):
IssueLinkRequester(
install=self.install,
group=self.group,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import pytest
import responses
from jsonschema import ValidationError

from sentry.coreapi import APIError
from sentry.sentry_apps.external_requests.select_requester import SelectRequester
from sentry.sentry_apps.services.app import app_service
from sentry.sentry_apps.utils.errors import SentryAppIntegratorError
from sentry.testutils.cases import TestCase
from sentry.utils.sentry_apps import SentryAppWebhookRequestsBuffer

Expand Down Expand Up @@ -70,7 +69,7 @@ def test_invalid_response_missing_label(self):
content_type="application/json",
)

with pytest.raises(ValidationError):
with pytest.raises(SentryAppIntegratorError):
SelectRequester(
install=self.install,
project_slug=self.project.slug,
Expand All @@ -91,7 +90,7 @@ def test_invalid_response_missing_value(self):
content_type="application/json",
)

with pytest.raises(ValidationError):
with pytest.raises(SentryAppIntegratorError):
SelectRequester(
install=self.install,
project_slug=self.project.slug,
Expand All @@ -107,7 +106,7 @@ def test_500_response(self):
status=500,
)

with pytest.raises(APIError):
with pytest.raises(SentryAppIntegratorError):
SelectRequester(
install=self.install,
project_slug=self.project.slug,
Expand All @@ -130,7 +129,7 @@ def test_api_error_message(self):
status=500,
)

with pytest.raises(APIError) as exception_info:
with pytest.raises(SentryAppIntegratorError) as exception_info:
SelectRequester(
install=self.install,
project_slug=self.project.slug,
Expand All @@ -152,7 +151,7 @@ def test_validation_error_message_validator(self):
status=200,
)

with pytest.raises(ValidationError) as exception_info:
with pytest.raises(SentryAppIntegratorError) as exception_info:
SelectRequester(
install=self.install,
project_slug=self.project.slug,
Expand All @@ -173,7 +172,7 @@ def test_validation_error_message_missing_field(self):
status=200,
)

with pytest.raises(ValidationError) as exception_info:
with pytest.raises(SentryAppIntegratorError) as exception_info:
SelectRequester(
install=self.install,
project_slug=self.project.slug,
Expand Down

0 comments on commit d18f463

Please sign in to comment.