From 8d469c3a977f74db1aedae757f2a9d379213774d Mon Sep 17 00:00:00 2001 From: Christinarlong <60594860+Christinarlong@users.noreply.github.com> Date: Wed, 18 Sep 2024 14:06:51 -0700 Subject: [PATCH] ref(sentry_apps): Move SentryAppInstallation model to sentry_apps (#77649) --- pyproject.toml | 1 - .../integrations/sentry_apps/components.py | 2 +- .../integrations/sentry_apps/details.py | 2 +- .../sentry_apps/installation/details.py | 2 +- .../sentry_apps/installation/index.py | 2 +- .../sentry_apps/internal_app_token/index.py | 2 +- .../integrations/sentry_apps/stats/details.py | 2 +- src/sentry/api/endpoints/project_index.py | 2 +- src/sentry/api/serializers/models/rule.py | 2 +- .../models/sentry_app_installation.py | 2 +- .../rest_framework/notification_action.py | 2 +- src/sentry/deletions/__init__.py | 5 +- src/sentry/deletions/defaults/sentry_app.py | 2 +- src/sentry/hybridcloud/apigateway/proxy.py | 2 +- .../endpoints/serializers/alert_rule.py | 2 +- .../integrations/services/integration/impl.py | 2 +- src/sentry/integrations/vercel/integration.py | 2 +- .../mediators/alert_rule_actions/creator.py | 2 +- .../alert_rule_action_requester.py | 2 +- .../installation_notifier.py | 2 +- .../sentry_app_installations/updater.py | 2 +- .../token_exchange/grant_exchanger.py | 2 +- .../mediators/token_exchange/refresher.py | 2 +- ..._squashed_0484_break_org_member_user_fk.py | 4 +- src/sentry/models/apitoken.py | 2 +- src/sentry/models/authprovider.py | 2 +- src/sentry/models/integrations/__init__.py | 2 - src/sentry/receivers/outbox/control.py | 2 +- src/sentry/sentry_apps/components.py | 2 +- src/sentry/sentry_apps/installations.py | 2 +- src/sentry/sentry_apps/logic.py | 2 +- src/sentry/sentry_apps/models/__init__.py | 3 +- src/sentry/sentry_apps/models/sentry_app.py | 2 +- .../models}/sentry_app_installation.py | 53 +------------------ src/sentry/sentry_apps/services/app/impl.py | 10 ++-- src/sentry/sentry_apps/services/app/serial.py | 2 +- src/sentry/tasks/sentry_apps.py | 2 +- src/sentry/testutils/factories.py | 2 +- .../utils/sentry_apps/service_hook_manager.py | 2 +- .../debug/debug_sentry_app_notify_disable.py | 2 +- ...t_organization_sentry_app_detailed_view.py | 2 +- .../test_sentry_app_external_issue_details.py | 2 +- .../test_sentry_app_external_issues.py | 2 +- .../test_sentry_app_installations.py | 2 +- ...t_organization_sentry_app_installations.py | 2 +- .../api/endpoints/test_sentry_app_details.py | 2 +- .../sentry/api/endpoints/test_sentry_apps.py | 2 +- tests/sentry/deletions/test_sentry_app.py | 2 +- .../test_sentry_app_installations.py | 2 +- .../test_sentry_installation_tokens.py | 2 +- ...ation_alert_rule_available_action_index.py | 3 +- .../integrations/vercel/test_integration.py | 2 +- .../token_exchange/test_grant_exchanger.py | 2 +- .../token_exchange/test_refresher.py | 2 +- tests/sentry/models/test_apitoken.py | 2 +- .../models/test_sentryappinstallationtoken.py | 2 +- .../utils/test_get_ratelimit_key.py | 2 +- tests/sentry/sentry_apps/models/__init__.py | 0 .../models/test_sentryappinstallation.py | 2 +- tests/sentry/sentry_apps/services/test_app.py | 2 +- .../sentry_apps/test_sentry_app_creator.py | 2 +- ...t_sentry_app_installation_token_creator.py | 2 +- tests/sentry/tasks/test_sentry_apps.py | 2 +- 63 files changed, 68 insertions(+), 121 deletions(-) rename src/sentry/{models/integrations => sentry_apps/models}/sentry_app_installation.py (80%) create mode 100644 tests/sentry/sentry_apps/models/__init__.py rename tests/sentry/{ => sentry_apps}/models/test_sentryappinstallation.py (96%) diff --git a/pyproject.toml b/pyproject.toml index a46c73d2839fe9..f2edc8910dd9bd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -296,7 +296,6 @@ module = [ "sentry.middleware.auth", "sentry.middleware.ratelimit", "sentry.middleware.superuser", - "sentry.models.integrations.sentry_app_installation", "sentry.models.organizationaccessrequest", "sentry.monitors.consumers.monitor_consumer", "sentry.monitors.endpoints.base", diff --git a/src/sentry/api/endpoints/integrations/sentry_apps/components.py b/src/sentry/api/endpoints/integrations/sentry_apps/components.py index d7b135069b15d6..1211c2094c3c5c 100644 --- a/src/sentry/api/endpoints/integrations/sentry_apps/components.py +++ b/src/sentry/api/endpoints/integrations/sentry_apps/components.py @@ -11,12 +11,12 @@ from sentry.api.serializers import serialize from sentry.coreapi import APIError from sentry.models.integrations.sentry_app_component import SentryAppComponent -from sentry.models.integrations.sentry_app_installation import SentryAppInstallation from sentry.organizations.services.organization.model import ( RpcOrganization, RpcUserOrganizationContext, ) from sentry.sentry_apps.components import SentryAppComponentPreparer +from sentry.sentry_apps.models.sentry_app_installation import SentryAppInstallation # TODO(mgaeta): These endpoints are doing the same thing, but one takes a diff --git a/src/sentry/api/endpoints/integrations/sentry_apps/details.py b/src/sentry/api/endpoints/integrations/sentry_apps/details.py index 0e848322c970cf..635361f7ce03ed 100644 --- a/src/sentry/api/endpoints/integrations/sentry_apps/details.py +++ b/src/sentry/api/endpoints/integrations/sentry_apps/details.py @@ -21,10 +21,10 @@ from sentry.auth.staff import is_active_staff from sentry.constants import SentryAppStatus from sentry.mediators.sentry_app_installations.installation_notifier import InstallationNotifier -from sentry.models.integrations.sentry_app_installation import SentryAppInstallation from sentry.organizations.services.organization import organization_service from sentry.sentry_apps.logic import SentryAppUpdater from sentry.sentry_apps.models.sentry_app import SentryApp +from sentry.sentry_apps.models.sentry_app_installation import SentryAppInstallation from sentry.utils.audit import create_audit_entry logger = logging.getLogger(__name__) diff --git a/src/sentry/api/endpoints/integrations/sentry_apps/installation/details.py b/src/sentry/api/endpoints/integrations/sentry_apps/installation/details.py index f6e17edf1d0d88..8d124ffb2814a4 100644 --- a/src/sentry/api/endpoints/integrations/sentry_apps/installation/details.py +++ b/src/sentry/api/endpoints/integrations/sentry_apps/installation/details.py @@ -13,7 +13,7 @@ from sentry.api.serializers.rest_framework import SentryAppInstallationSerializer from sentry.mediators.sentry_app_installations.installation_notifier import InstallationNotifier from sentry.mediators.sentry_app_installations.updater import Updater -from sentry.models.integrations.sentry_app_installation import SentryAppInstallation +from sentry.sentry_apps.models.sentry_app_installation import SentryAppInstallation from sentry.utils.audit import create_audit_entry diff --git a/src/sentry/api/endpoints/integrations/sentry_apps/installation/index.py b/src/sentry/api/endpoints/integrations/sentry_apps/installation/index.py index 4a0b8553464f18..5e2be9dfecbdfa 100644 --- a/src/sentry/api/endpoints/integrations/sentry_apps/installation/index.py +++ b/src/sentry/api/endpoints/integrations/sentry_apps/installation/index.py @@ -14,9 +14,9 @@ from sentry.constants import SENTRY_APP_SLUG_MAX_LENGTH, SentryAppStatus from sentry.features.exceptions import FeatureNotRegistered from sentry.integrations.models.integration_feature import IntegrationFeature, IntegrationTypes -from sentry.models.integrations.sentry_app_installation import SentryAppInstallation from sentry.sentry_apps.installations import SentryAppInstallationCreator from sentry.sentry_apps.models.sentry_app import SentryApp +from sentry.sentry_apps.models.sentry_app_installation import SentryAppInstallation class SentryAppInstallationsSerializer(serializers.Serializer): diff --git a/src/sentry/api/endpoints/integrations/sentry_apps/internal_app_token/index.py b/src/sentry/api/endpoints/integrations/sentry_apps/internal_app_token/index.py index 376ef35414bc9a..0999cf93d6cc35 100644 --- a/src/sentry/api/endpoints/integrations/sentry_apps/internal_app_token/index.py +++ b/src/sentry/api/endpoints/integrations/sentry_apps/internal_app_token/index.py @@ -13,9 +13,9 @@ from sentry.api.serializers.models.apitoken import ApiTokenSerializer from sentry.exceptions import ApiTokenLimitError from sentry.models.apitoken import ApiToken -from sentry.models.integrations.sentry_app_installation import SentryAppInstallation from sentry.sentry_apps.installations import SentryAppInstallationTokenCreator from sentry.sentry_apps.models.sentry_app import MASKED_VALUE +from sentry.sentry_apps.models.sentry_app_installation import SentryAppInstallation @control_silo_endpoint diff --git a/src/sentry/api/endpoints/integrations/sentry_apps/stats/details.py b/src/sentry/api/endpoints/integrations/sentry_apps/stats/details.py index 8f10ec705bb496..34dc8f7fb9ce7d 100644 --- a/src/sentry/api/endpoints/integrations/sentry_apps/stats/details.py +++ b/src/sentry/api/endpoints/integrations/sentry_apps/stats/details.py @@ -5,7 +5,7 @@ from sentry.api.api_publish_status import ApiPublishStatus from sentry.api.base import StatsMixin, control_silo_endpoint from sentry.api.bases import SentryAppBaseEndpoint, SentryAppStatsPermission -from sentry.models.integrations.sentry_app_installation import SentryAppInstallation +from sentry.sentry_apps.models.sentry_app_installation import SentryAppInstallation @control_silo_endpoint diff --git a/src/sentry/api/endpoints/project_index.py b/src/sentry/api/endpoints/project_index.py index 869d476e10cdd2..b0b3a8c99f2ccd 100644 --- a/src/sentry/api/endpoints/project_index.py +++ b/src/sentry/api/endpoints/project_index.py @@ -12,10 +12,10 @@ from sentry.auth.superuser import is_active_superuser from sentry.constants import ObjectStatus from sentry.db.models.query import in_iexact -from sentry.models.integrations.sentry_app_installation import SentryAppInstallation from sentry.models.project import Project from sentry.models.projectplatform import ProjectPlatform from sentry.search.utils import tokenize_query +from sentry.sentry_apps.models.sentry_app_installation import SentryAppInstallation @region_silo_endpoint diff --git a/src/sentry/api/serializers/models/rule.py b/src/sentry/api/serializers/models/rule.py index 52910f726ee9b1..025541ba58e966 100644 --- a/src/sentry/api/serializers/models/rule.py +++ b/src/sentry/api/serializers/models/rule.py @@ -7,10 +7,10 @@ from sentry.api.serializers import Serializer, register from sentry.constants import ObjectStatus from sentry.models.environment import Environment -from sentry.models.integrations.sentry_app_installation import prepare_ui_component from sentry.models.rule import NeglectedRule, Rule, RuleActivity, RuleActivityType from sentry.models.rulefirehistory import RuleFireHistory from sentry.models.rulesnooze import RuleSnooze +from sentry.sentry_apps.models.sentry_app_installation import prepare_ui_component from sentry.sentry_apps.services.app.model import RpcSentryAppComponentContext from sentry.users.services.user.service import user_service diff --git a/src/sentry/api/serializers/models/sentry_app_installation.py b/src/sentry/api/serializers/models/sentry_app_installation.py index 418b770cfb6522..c21d0ac32e29d6 100644 --- a/src/sentry/api/serializers/models/sentry_app_installation.py +++ b/src/sentry/api/serializers/models/sentry_app_installation.py @@ -6,8 +6,8 @@ from sentry.api.serializers import Serializer, register from sentry.constants import SentryAppInstallationStatus from sentry.hybridcloud.services.organization_mapping import organization_mapping_service -from sentry.models.integrations.sentry_app_installation import SentryAppInstallation from sentry.sentry_apps.models.sentry_app import SentryApp +from sentry.sentry_apps.models.sentry_app_installation import SentryAppInstallation from sentry.users.models.user import User from sentry.users.services.user import RpcUser diff --git a/src/sentry/api/serializers/rest_framework/notification_action.py b/src/sentry/api/serializers/rest_framework/notification_action.py index 2b1106435484ae..98f2048de063e6 100644 --- a/src/sentry/api/serializers/rest_framework/notification_action.py +++ b/src/sentry/api/serializers/rest_framework/notification_action.py @@ -9,9 +9,9 @@ from sentry.constants import SentryAppInstallationStatus from sentry.integrations.services.integration import integration_service from sentry.integrations.slack.utils.channel import get_channel_id, validate_channel_id -from sentry.models.integrations.sentry_app_installation import SentryAppInstallation from sentry.models.notificationaction import ActionService, ActionTarget, NotificationAction from sentry.models.project import Project +from sentry.sentry_apps.models.sentry_app_installation import SentryAppInstallation from sentry.utils.strings import oxfordize_list diff --git a/src/sentry/deletions/__init__.py b/src/sentry/deletions/__init__.py index 831a0ebe99a70e..8096f3c9b213b1 100644 --- a/src/sentry/deletions/__init__.py +++ b/src/sentry/deletions/__init__.py @@ -100,6 +100,7 @@ def load_defaults() -> None: from sentry.models.rulefirehistory import RuleFireHistory from sentry.monitors import models as monitor_models from sentry.sentry_apps.models.sentry_app import SentryApp + from sentry.sentry_apps.models.sentry_app_installation import SentryAppInstallation from sentry.snuba import models as snuba_models from . import defaults @@ -165,9 +166,7 @@ def load_defaults() -> None: RepositoryProjectPathConfig, defaults.RepositoryProjectPathConfigDeletionTask ) default_manager.register(SentryApp, defaults.SentryAppDeletionTask) - default_manager.register( - models.SentryAppInstallation, defaults.SentryAppInstallationDeletionTask - ) + default_manager.register(SentryAppInstallation, defaults.SentryAppInstallationDeletionTask) default_manager.register( models.SentryAppInstallationToken, defaults.SentryAppInstallationTokenDeletionTask ) diff --git a/src/sentry/deletions/defaults/sentry_app.py b/src/sentry/deletions/defaults/sentry_app.py index c3a6f7e66c22e3..a6549af04a85e3 100644 --- a/src/sentry/deletions/defaults/sentry_app.py +++ b/src/sentry/deletions/defaults/sentry_app.py @@ -4,7 +4,7 @@ class SentryAppDeletionTask(ModelDeletionTask): def get_child_relations(self, instance): from sentry.models.apiapplication import ApiApplication - from sentry.models.integrations.sentry_app_installation import SentryAppInstallation + from sentry.sentry_apps.models.sentry_app_installation import SentryAppInstallation from sentry.users.models.user import User return [ diff --git a/src/sentry/hybridcloud/apigateway/proxy.py b/src/sentry/hybridcloud/apigateway/proxy.py index da301b31987236..e84cf0722f3680 100644 --- a/src/sentry/hybridcloud/apigateway/proxy.py +++ b/src/sentry/hybridcloud/apigateway/proxy.py @@ -18,9 +18,9 @@ from sentry import options from sentry.api.exceptions import RequestTimeout -from sentry.models.integrations.sentry_app_installation import SentryAppInstallation from sentry.models.organizationmapping import OrganizationMapping from sentry.sentry_apps.models.sentry_app import SentryApp +from sentry.sentry_apps.models.sentry_app_installation import SentryAppInstallation from sentry.silo.util import ( PROXY_DIRECT_LOCATION_HEADER, clean_outbound_headers, diff --git a/src/sentry/incidents/endpoints/serializers/alert_rule.py b/src/sentry/incidents/endpoints/serializers/alert_rule.py index f40f3e5e1c2c63..0ec511f596727c 100644 --- a/src/sentry/incidents/endpoints/serializers/alert_rule.py +++ b/src/sentry/incidents/endpoints/serializers/alert_rule.py @@ -23,9 +23,9 @@ ) from sentry.incidents.models.alert_rule_activations import AlertRuleActivations from sentry.incidents.models.incident import Incident -from sentry.models.integrations.sentry_app_installation import prepare_ui_component from sentry.models.rule import Rule from sentry.models.rulesnooze import RuleSnooze +from sentry.sentry_apps.models.sentry_app_installation import prepare_ui_component from sentry.sentry_apps.services.app import app_service from sentry.sentry_apps.services.app.model import RpcSentryAppComponentContext from sentry.snuba.models import SnubaQueryEventType diff --git a/src/sentry/integrations/services/integration/impl.py b/src/sentry/integrations/services/integration/impl.py index c47cfa906d9274..169e0679970058 100644 --- a/src/sentry/integrations/services/integration/impl.py +++ b/src/sentry/integrations/services/integration/impl.py @@ -34,9 +34,9 @@ serialize_integration_external_project, serialize_organization_integration, ) -from sentry.models.integrations.sentry_app_installation import SentryAppInstallation from sentry.rules.actions.notify_event_service import find_alert_rule_action_ui_component from sentry.sentry_apps.models.sentry_app import SentryApp +from sentry.sentry_apps.models.sentry_app_installation import SentryAppInstallation from sentry.shared_integrations.exceptions import ApiError from sentry.utils import json, metrics from sentry.utils.sentry_apps import send_and_save_webhook_request diff --git a/src/sentry/integrations/vercel/integration.py b/src/sentry/integrations/vercel/integration.py index 49b42fd4997839..45068ff401d777 100644 --- a/src/sentry/integrations/vercel/integration.py +++ b/src/sentry/integrations/vercel/integration.py @@ -19,7 +19,6 @@ ) from sentry.integrations.models.integration import Integration from sentry.integrations.services.integration import integration_service -from sentry.models.integrations.sentry_app_installation import SentryAppInstallation from sentry.models.integrations.sentry_app_installation_for_provider import ( SentryAppInstallationForProvider, ) @@ -28,6 +27,7 @@ from sentry.pipeline import NestedPipelineView from sentry.projects.services.project_key import project_key_service from sentry.sentry_apps.logic import SentryAppCreator +from sentry.sentry_apps.models.sentry_app_installation import SentryAppInstallation from sentry.shared_integrations.exceptions import ApiError, IntegrationError from sentry.users.models.user import User from sentry.utils.http import absolute_uri diff --git a/src/sentry/mediators/alert_rule_actions/creator.py b/src/sentry/mediators/alert_rule_actions/creator.py index 1b2435ed0b73c5..df43ea9cb0f291 100644 --- a/src/sentry/mediators/alert_rule_actions/creator.py +++ b/src/sentry/mediators/alert_rule_actions/creator.py @@ -9,7 +9,7 @@ from sentry.mediators.mediator import Mediator from sentry.mediators.param import Param from sentry.models.integrations.sentry_app_component import SentryAppComponent -from sentry.models.integrations.sentry_app_installation import SentryAppInstallation +from sentry.sentry_apps.models.sentry_app_installation import SentryAppInstallation class AlertRuleActionCreator(Mediator): diff --git a/src/sentry/mediators/external_requests/alert_rule_action_requester.py b/src/sentry/mediators/external_requests/alert_rule_action_requester.py index ec7519b41614a5..839e89baa4a306 100644 --- a/src/sentry/mediators/external_requests/alert_rule_action_requester.py +++ b/src/sentry/mediators/external_requests/alert_rule_action_requester.py @@ -11,7 +11,7 @@ from sentry.mediators.external_requests.util import send_and_save_sentry_app_request from sentry.mediators.mediator import Mediator from sentry.mediators.param import Param -from sentry.models.integrations.sentry_app_installation import SentryAppInstallation +from sentry.sentry_apps.models.sentry_app_installation import SentryAppInstallation from sentry.utils import json logger = logging.getLogger("sentry.mediators.external-requests") diff --git a/src/sentry/mediators/sentry_app_installations/installation_notifier.py b/src/sentry/mediators/sentry_app_installations/installation_notifier.py index 462cf74395fa27..bb37880dfcda90 100644 --- a/src/sentry/mediators/sentry_app_installations/installation_notifier.py +++ b/src/sentry/mediators/sentry_app_installations/installation_notifier.py @@ -6,8 +6,8 @@ from sentry.mediators.mediator import Mediator from sentry.mediators.param import Param from sentry.models.apigrant import ApiGrant -from sentry.models.integrations.sentry_app_installation import SentryAppInstallation from sentry.sentry_apps.models.sentry_app import SentryApp +from sentry.sentry_apps.models.sentry_app_installation import SentryAppInstallation from sentry.users.services.user.model import RpcUser from sentry.utils.sentry_apps import send_and_save_webhook_request diff --git a/src/sentry/mediators/sentry_app_installations/updater.py b/src/sentry/mediators/sentry_app_installations/updater.py index feb733866ce61c..4a6fac446b8c28 100644 --- a/src/sentry/mediators/sentry_app_installations/updater.py +++ b/src/sentry/mediators/sentry_app_installations/updater.py @@ -4,7 +4,7 @@ from sentry.constants import SentryAppInstallationStatus from sentry.mediators.mediator import Mediator from sentry.mediators.param import Param -from sentry.models.integrations.sentry_app_installation import SentryAppInstallation +from sentry.sentry_apps.models.sentry_app_installation import SentryAppInstallation from sentry.sentry_apps.services.app import RpcSentryAppInstallation diff --git a/src/sentry/mediators/token_exchange/grant_exchanger.py b/src/sentry/mediators/token_exchange/grant_exchanger.py index ac350523ca1e88..53a697ed36802e 100644 --- a/src/sentry/mediators/token_exchange/grant_exchanger.py +++ b/src/sentry/mediators/token_exchange/grant_exchanger.py @@ -12,8 +12,8 @@ from sentry.models.apiapplication import ApiApplication from sentry.models.apigrant import ApiGrant from sentry.models.apitoken import ApiToken -from sentry.models.integrations.sentry_app_installation import SentryAppInstallation from sentry.sentry_apps.models.sentry_app import SentryApp +from sentry.sentry_apps.models.sentry_app_installation import SentryAppInstallation from sentry.sentry_apps.services.app import RpcSentryAppInstallation from sentry.silo.safety import unguarded_write from sentry.users.models.user import User diff --git a/src/sentry/mediators/token_exchange/refresher.py b/src/sentry/mediators/token_exchange/refresher.py index 0988719f47178c..08bdb2d0bcd547 100644 --- a/src/sentry/mediators/token_exchange/refresher.py +++ b/src/sentry/mediators/token_exchange/refresher.py @@ -9,8 +9,8 @@ from sentry.mediators.token_exchange.validator import Validator from sentry.models.apiapplication import ApiApplication from sentry.models.apitoken import ApiToken -from sentry.models.integrations.sentry_app_installation import SentryAppInstallation from sentry.sentry_apps.models.sentry_app import SentryApp +from sentry.sentry_apps.models.sentry_app_installation import SentryAppInstallation from sentry.sentry_apps.services.app import RpcSentryAppInstallation from sentry.users.models.user import User diff --git a/src/sentry/migrations/0001_squashed_0484_break_org_member_user_fk.py b/src/sentry/migrations/0001_squashed_0484_break_org_member_user_fk.py index aec705c0495561..a0e34f1cc57827 100644 --- a/src/sentry/migrations/0001_squashed_0484_break_org_member_user_fk.py +++ b/src/sentry/migrations/0001_squashed_0484_break_org_member_user_fk.py @@ -31,10 +31,10 @@ import sentry.models.apitoken import sentry.models.broadcast import sentry.models.groupshare -import sentry.models.integrations.sentry_app_installation import sentry.models.scheduledeletion import sentry.models.servicehook import sentry.sentry_apps.models.sentry_app +import sentry.sentry_apps.models.sentry_app_installation import sentry.users.models.authenticator import sentry.users.models.user import sentry.utils.security.hash @@ -1961,7 +1961,7 @@ class Migration(CheckedMigration): ( "uuid", models.CharField( - default=sentry.models.integrations.sentry_app_installation.default_uuid, + default=sentry.sentry_apps.models.sentry_app_installation.default_uuid, max_length=64, ), ), diff --git a/src/sentry/models/apitoken.py b/src/sentry/models/apitoken.py index 5cdedb0d1605e6..743592f28a20fd 100644 --- a/src/sentry/models/apitoken.py +++ b/src/sentry/models/apitoken.py @@ -351,10 +351,10 @@ def sanitize_relocation_json( @property def organization_id(self) -> int | None: - from sentry.models.integrations.sentry_app_installation import SentryAppInstallation from sentry.models.integrations.sentry_app_installation_token import ( SentryAppInstallationToken, ) + from sentry.sentry_apps.models.sentry_app_installation import SentryAppInstallation try: installation = SentryAppInstallation.objects.get_by_api_token(self.id).get() diff --git a/src/sentry/models/authprovider.py b/src/sentry/models/authprovider.py index 24fa7983de9428..1e6c5ea4a5281d 100644 --- a/src/sentry/models/authprovider.py +++ b/src/sentry/models/authprovider.py @@ -122,11 +122,11 @@ def get_scim_token(self): return get_scim_token(self.flags.scim_enabled, self.organization_id, self.provider) def enable_scim(self, user): - from sentry.models.integrations.sentry_app_installation import SentryAppInstallation from sentry.models.integrations.sentry_app_installation_for_provider import ( SentryAppInstallationForProvider, ) from sentry.sentry_apps.logic import SentryAppCreator + from sentry.sentry_apps.models.sentry_app_installation import SentryAppInstallation if ( not self.get_provider().can_use_scim(self.organization_id, user) diff --git a/src/sentry/models/integrations/__init__.py b/src/sentry/models/integrations/__init__.py index bd3e6b4842da80..4e073fcc530d95 100644 --- a/src/sentry/models/integrations/__init__.py +++ b/src/sentry/models/integrations/__init__.py @@ -1,7 +1,6 @@ __all__ = ( "SentryApp", "SentryAppComponent", - "SentryAppInstallation", "SentryAppInstallationForProvider", "SentryAppInstallationToken", ) @@ -10,7 +9,6 @@ # REQUIRED for migrations to run. from sentry.integrations.types import ExternalProviders # NOQA from sentry.models.integrations.sentry_app_component import SentryAppComponent -from sentry.models.integrations.sentry_app_installation import SentryAppInstallation from sentry.models.integrations.sentry_app_installation_for_provider import ( SentryAppInstallationForProvider, ) diff --git a/src/sentry/receivers/outbox/control.py b/src/sentry/receivers/outbox/control.py index b826a66ecedcf2..fa0bb317ca7a84 100644 --- a/src/sentry/receivers/outbox/control.py +++ b/src/sentry/receivers/outbox/control.py @@ -22,12 +22,12 @@ from sentry.issues.services.issue import issue_service from sentry.models.apiapplication import ApiApplication from sentry.models.files.utils import get_relocation_storage -from sentry.models.integrations.sentry_app_installation import SentryAppInstallation from sentry.models.organizationmapping import OrganizationMapping from sentry.organizations.services.organization import RpcOrganizationSignal, organization_service from sentry.receivers.outbox import maybe_process_tombstone from sentry.relocation.services.relocation_export.service import region_relocation_export_service from sentry.sentry_apps.models.sentry_app import SentryApp +from sentry.sentry_apps.models.sentry_app_installation import SentryAppInstallation from sentry.sentry_apps.services.app.service import get_by_application_id, get_installation logger = logging.getLogger(__name__) diff --git a/src/sentry/sentry_apps/components.py b/src/sentry/sentry_apps/components.py index 6047954930dd0c..8fc3811372226a 100644 --- a/src/sentry/sentry_apps/components.py +++ b/src/sentry/sentry_apps/components.py @@ -10,7 +10,7 @@ from sentry.mediators.external_requests.select_requester import SelectRequester from sentry.models.integrations.sentry_app_component import SentryAppComponent -from sentry.models.integrations.sentry_app_installation import SentryAppInstallation +from sentry.sentry_apps.models.sentry_app_installation import SentryAppInstallation from sentry.sentry_apps.services.app.model import RpcSentryAppComponent, RpcSentryAppInstallation from sentry.sentry_apps.services.app.serial import serialize_sentry_app_installation from sentry.utils import json diff --git a/src/sentry/sentry_apps/installations.py b/src/sentry/sentry_apps/installations.py index 14a8532bc81862..f37a81444acadc 100644 --- a/src/sentry/sentry_apps/installations.py +++ b/src/sentry/sentry_apps/installations.py @@ -13,9 +13,9 @@ from sentry.models.apiapplication import ApiApplication from sentry.models.apigrant import ApiGrant from sentry.models.apitoken import ApiToken -from sentry.models.integrations.sentry_app_installation import SentryAppInstallation from sentry.models.integrations.sentry_app_installation_token import SentryAppInstallationToken from sentry.sentry_apps.models.sentry_app import SentryApp +from sentry.sentry_apps.models.sentry_app_installation import SentryAppInstallation from sentry.sentry_apps.services.hook import hook_service from sentry.tasks.sentry_apps import installation_webhook from sentry.users.models.user import User diff --git a/src/sentry/sentry_apps/logic.py b/src/sentry/sentry_apps/logic.py index 6dbd83f5315bb4..102b11f9633562 100644 --- a/src/sentry/sentry_apps/logic.py +++ b/src/sentry/sentry_apps/logic.py @@ -25,7 +25,6 @@ from sentry.models.apiscopes import add_scope_hierarchy from sentry.models.apitoken import ApiToken from sentry.models.integrations.sentry_app_component import SentryAppComponent -from sentry.models.integrations.sentry_app_installation import SentryAppInstallation from sentry.sentry_apps.installations import ( SentryAppInstallationCreator, SentryAppInstallationTokenCreator, @@ -37,6 +36,7 @@ SentryApp, default_uuid, ) +from sentry.sentry_apps.models.sentry_app_installation import SentryAppInstallation from sentry.tasks.sentry_apps import create_or_update_service_hooks_for_sentry_app from sentry.users.models.user import User from sentry.users.services.user.model import RpcUser diff --git a/src/sentry/sentry_apps/models/__init__.py b/src/sentry/sentry_apps/models/__init__.py index 7429e9d8142365..c2665e429fdb8a 100644 --- a/src/sentry/sentry_apps/models/__init__.py +++ b/src/sentry/sentry_apps/models/__init__.py @@ -1,3 +1,4 @@ from .sentry_app import SentryApp +from .sentry_app_installation import SentryAppInstallation -__all__ = ("SentryApp",) +__all__ = ("SentryApp", "SentryAppInstallation") diff --git a/src/sentry/sentry_apps/models/sentry_app.py b/src/sentry/sentry_apps/models/sentry_app.py index 84d04faa63fece..9b7f2372120443 100644 --- a/src/sentry/sentry_apps/models/sentry_app.py +++ b/src/sentry/sentry_apps/models/sentry_app.py @@ -204,7 +204,7 @@ def update(self, *args, **kwargs): return result def is_installed_on(self, organization): - from sentry.models.integrations.sentry_app_installation import SentryAppInstallation + from sentry.sentry_apps.models.sentry_app_installation import SentryAppInstallation return SentryAppInstallation.objects.filter( organization_id=organization.id, diff --git a/src/sentry/models/integrations/sentry_app_installation.py b/src/sentry/sentry_apps/models/sentry_app_installation.py similarity index 80% rename from src/sentry/models/integrations/sentry_app_installation.py rename to src/sentry/sentry_apps/models/sentry_app_installation.py index 9faee1f3f2a0ed..4fb3a26de80c91 100644 --- a/src/sentry/models/integrations/sentry_app_installation.py +++ b/src/sentry/sentry_apps/models/sentry_app_installation.py @@ -2,11 +2,10 @@ import uuid from collections.abc import Collection, Mapping -from itertools import chain from typing import TYPE_CHECKING, Any, ClassVar, overload from django.db import models -from django.db.models import OuterRef, QuerySet, Subquery +from django.db.models import QuerySet from django.utils import timezone from sentry.auth.services.auth import AuthenticatedToken @@ -56,48 +55,6 @@ def get_projects(self, token: ApiToken | AuthenticatedToken) -> QuerySet[Project return Project.objects.filter(organization_id=token.organization_id) - def get_related_sentry_app_components( - self, - organization_ids: list[int], - sentry_app_ids: list[int], - type: str, - group_by="sentry_app_id", - ): - from sentry.models.integrations.sentry_app_component import SentryAppComponent - - component_query = SentryAppComponent.objects.filter( - sentry_app_id=OuterRef("sentry_app_id"), type=type - ) - - sentry_app_installations = ( - self.filter(**self.get_organization_filter_kwargs(organization_ids)) - .filter(sentry_app_id__in=sentry_app_ids) - .annotate( - # Cannot annotate model object only individual fields. We can convert it into SentryAppComponent instance later. - sentry_app_component_id=Subquery(component_query.values("id")[:1]), - sentry_app_component_schema=Subquery(component_query.values("schema")[:1]), - sentry_app_component_uuid=Subquery(component_query.values("uuid")[:1]), - ) - .filter(sentry_app_component_id__isnull=False) - ) - - # There should only be 1 install of a SentryApp per organization - grouped_sentry_app_installations = { - getattr(install, group_by): { - "sentry_app_installation": install.to_dict(), - "sentry_app_component": { - "id": install.sentry_app_component_id, - "type": type, - "schema": install.sentry_app_component_schema, - "uuid": install.sentry_app_component_uuid, - "sentry_app_id": install.sentry_app_id, - }, - } - for install in sentry_app_installations - } - - return grouped_sentry_app_installations - @control_silo_model class SentryAppInstallation(ReplicatedControlModel, ParanoidModel): @@ -156,14 +113,6 @@ class Meta: # grant code should be included in the serialization. is_new = False - def to_dict(self): - opts = self._meta - data = {} - for field in chain(opts.concrete_fields, opts.private_fields, opts.many_to_many): - field_name = field.get_attname() - data[field_name] = self.serializable_value(field_name) - return data - def save(self, *args, **kwargs): self.date_updated = timezone.now() return super().save(*args, **kwargs) diff --git a/src/sentry/sentry_apps/services/app/impl.py b/src/sentry/sentry_apps/services/app/impl.py index 81ffa6e90fd1d7..c72db356434989 100644 --- a/src/sentry/sentry_apps/services/app/impl.py +++ b/src/sentry/sentry_apps/services/app/impl.py @@ -12,13 +12,13 @@ from sentry.hybridcloud.rpc.filter_query import FilterQueryDatabaseImpl, OpaqueSerializedResponse from sentry.mediators import alert_rule_actions from sentry.models.integrations.sentry_app_component import SentryAppComponent -from sentry.models.integrations.sentry_app_installation import ( - SentryAppInstallation, - prepare_sentry_app_components, -) from sentry.models.integrations.sentry_app_installation_token import SentryAppInstallationToken from sentry.sentry_apps.logic import SentryAppCreator from sentry.sentry_apps.models.sentry_app import SentryApp +from sentry.sentry_apps.models.sentry_app_installation import ( + SentryAppInstallation, + prepare_sentry_app_components, +) from sentry.sentry_apps.services.app import ( AppService, RpcAlertRuleActionResult, @@ -307,7 +307,7 @@ def create_internal_integration_for_channel_request( def prepare_sentry_app_components( self, *, installation_id: int, component_type: str, project_slug: str | None = None ) -> RpcSentryAppComponent | None: - from sentry.models.integrations.sentry_app_installation import prepare_sentry_app_components + from sentry.sentry_apps.models.sentry_app_installation import prepare_sentry_app_components installation = SentryAppInstallation.objects.get(id=installation_id) component = prepare_sentry_app_components(installation, component_type, project_slug) diff --git a/src/sentry/sentry_apps/services/app/serial.py b/src/sentry/sentry_apps/services/app/serial.py index 0f06d3d20729c4..71a6abcdd2ed84 100644 --- a/src/sentry/sentry_apps/services/app/serial.py +++ b/src/sentry/sentry_apps/services/app/serial.py @@ -2,8 +2,8 @@ from sentry.models.apiapplication import ApiApplication from sentry.models.apitoken import ApiToken from sentry.models.integrations import SentryAppComponent -from sentry.models.integrations.sentry_app_installation import SentryAppInstallation from sentry.sentry_apps.models.sentry_app import SentryApp +from sentry.sentry_apps.models.sentry_app_installation import SentryAppInstallation from sentry.sentry_apps.services.app import ( RpcApiApplication, RpcSentryApp, diff --git a/src/sentry/tasks/sentry_apps.py b/src/sentry/tasks/sentry_apps.py index a664fac1389e7d..3b02bddab29162 100644 --- a/src/sentry/tasks/sentry_apps.py +++ b/src/sentry/tasks/sentry_apps.py @@ -14,11 +14,11 @@ from sentry.eventstore.models import Event, GroupEvent from sentry.models.activity import Activity from sentry.models.group import Group -from sentry.models.integrations.sentry_app_installation import SentryAppInstallation from sentry.models.organization import Organization from sentry.models.project import Project from sentry.models.servicehook import ServiceHook, ServiceHookProject from sentry.sentry_apps.models.sentry_app import VALID_EVENTS +from sentry.sentry_apps.models.sentry_app_installation import SentryAppInstallation from sentry.sentry_apps.services.app.service import app_service from sentry.shared_integrations.exceptions import ApiHostError, ApiTimeoutError, ClientError from sentry.silo.base import SiloMode diff --git a/src/sentry/testutils/factories.py b/src/sentry/testutils/factories.py index dbdc21980a3b91..e316e6ae9ed13a 100644 --- a/src/sentry/testutils/factories.py +++ b/src/sentry/testutils/factories.py @@ -101,7 +101,6 @@ from sentry.models.grouphistory import GroupHistory from sentry.models.grouplink import GroupLink from sentry.models.grouprelease import GroupRelease -from sentry.models.integrations.sentry_app_installation import SentryAppInstallation from sentry.models.integrations.sentry_app_installation_for_provider import ( SentryAppInstallationForProvider, ) @@ -142,6 +141,7 @@ ) from sentry.sentry_apps.logic import SentryAppCreator from sentry.sentry_apps.models.sentry_app import SentryApp +from sentry.sentry_apps.models.sentry_app_installation import SentryAppInstallation from sentry.sentry_apps.services.app.serial import serialize_sentry_app_installation from sentry.sentry_apps.services.hook import hook_service from sentry.signals import project_created diff --git a/src/sentry/utils/sentry_apps/service_hook_manager.py b/src/sentry/utils/sentry_apps/service_hook_manager.py index 788671650eb8af..58af41a48b1b41 100644 --- a/src/sentry/utils/sentry_apps/service_hook_manager.py +++ b/src/sentry/utils/sentry_apps/service_hook_manager.py @@ -1,4 +1,4 @@ -from sentry.models.integrations.sentry_app_installation import SentryAppInstallation +from sentry.sentry_apps.models.sentry_app_installation import SentryAppInstallation from sentry.sentry_apps.services.hook import hook_service diff --git a/src/sentry/web/frontend/debug/debug_sentry_app_notify_disable.py b/src/sentry/web/frontend/debug/debug_sentry_app_notify_disable.py index a919a993d464e5..53df7c98ce44f5 100644 --- a/src/sentry/web/frontend/debug/debug_sentry_app_notify_disable.py +++ b/src/sentry/web/frontend/debug/debug_sentry_app_notify_disable.py @@ -3,9 +3,9 @@ from sentry.constants import SentryAppStatus from sentry.integrations.notify_disable import get_provider_type, get_url -from sentry.models.integrations.sentry_app_installation import SentryAppInstallation from sentry.models.organization import Organization from sentry.sentry_apps.models.sentry_app import SentryApp +from sentry.sentry_apps.models.sentry_app_installation import SentryAppInstallation from .mail import MailPreview diff --git a/tests/acceptance/test_organization_sentry_app_detailed_view.py b/tests/acceptance/test_organization_sentry_app_detailed_view.py index 17886272691f51..a7f1f9712ea464 100644 --- a/tests/acceptance/test_organization_sentry_app_detailed_view.py +++ b/tests/acceptance/test_organization_sentry_app_detailed_view.py @@ -1,7 +1,7 @@ from fixtures.page_objects.organization_integration_settings import ( OrganizationSentryAppDetailViewPage, ) -from sentry.models.integrations.sentry_app_installation import SentryAppInstallation +from sentry.sentry_apps.models.sentry_app_installation import SentryAppInstallation from sentry.testutils.cases import AcceptanceTestCase from sentry.testutils.silo import no_silo_test diff --git a/tests/apidocs/endpoints/integration_platform/test_sentry_app_external_issue_details.py b/tests/apidocs/endpoints/integration_platform/test_sentry_app_external_issue_details.py index eb5170a2783f2d..a6dd6a71d58624 100644 --- a/tests/apidocs/endpoints/integration_platform/test_sentry_app_external_issue_details.py +++ b/tests/apidocs/endpoints/integration_platform/test_sentry_app_external_issue_details.py @@ -2,7 +2,7 @@ from django.urls import reverse from fixtures.apidocs_test_case import APIDocsTestCase -from sentry.models.integrations.sentry_app_installation import SentryAppInstallation +from sentry.sentry_apps.models.sentry_app_installation import SentryAppInstallation from sentry.silo.base import SiloMode from sentry.testutils.silo import assume_test_silo_mode diff --git a/tests/apidocs/endpoints/integration_platform/test_sentry_app_external_issues.py b/tests/apidocs/endpoints/integration_platform/test_sentry_app_external_issues.py index a5c112980756b9..24ea0557ff8af7 100644 --- a/tests/apidocs/endpoints/integration_platform/test_sentry_app_external_issues.py +++ b/tests/apidocs/endpoints/integration_platform/test_sentry_app_external_issues.py @@ -2,7 +2,7 @@ from django.urls import reverse from fixtures.apidocs_test_case import APIDocsTestCase -from sentry.models.integrations.sentry_app_installation import SentryAppInstallation +from sentry.sentry_apps.models.sentry_app_installation import SentryAppInstallation from sentry.silo.base import SiloMode from sentry.testutils.silo import assume_test_silo_mode diff --git a/tests/apidocs/endpoints/integration_platform/test_sentry_app_installations.py b/tests/apidocs/endpoints/integration_platform/test_sentry_app_installations.py index 141a12b9c6f524..3d2197ac3968b6 100644 --- a/tests/apidocs/endpoints/integration_platform/test_sentry_app_installations.py +++ b/tests/apidocs/endpoints/integration_platform/test_sentry_app_installations.py @@ -2,7 +2,7 @@ from django.urls import reverse from fixtures.apidocs_test_case import APIDocsTestCase -from sentry.models.integrations.sentry_app_installation import SentryAppInstallation +from sentry.sentry_apps.models.sentry_app_installation import SentryAppInstallation from sentry.testutils.silo import control_silo_test diff --git a/tests/sentry/api/endpoints/test_organization_sentry_app_installations.py b/tests/sentry/api/endpoints/test_organization_sentry_app_installations.py index 0ecc7168cb17a8..78f18885024344 100644 --- a/tests/sentry/api/endpoints/test_organization_sentry_app_installations.py +++ b/tests/sentry/api/endpoints/test_organization_sentry_app_installations.py @@ -2,8 +2,8 @@ from sentry.constants import SentryAppStatus from sentry.integrations.models.integration_feature import Feature -from sentry.models.integrations.sentry_app_installation import SentryAppInstallation from sentry.sentry_apps.logic import SentryAppUpdater +from sentry.sentry_apps.models.sentry_app_installation import SentryAppInstallation from sentry.slug.errors import DEFAULT_SLUG_ERROR_MESSAGE from sentry.testutils.cases import APITestCase from sentry.testutils.helpers.features import with_feature diff --git a/tests/sentry/api/endpoints/test_sentry_app_details.py b/tests/sentry/api/endpoints/test_sentry_app_details.py index 9344b03c073a94..e64340bc1de9e1 100644 --- a/tests/sentry/api/endpoints/test_sentry_app_details.py +++ b/tests/sentry/api/endpoints/test_sentry_app_details.py @@ -8,10 +8,10 @@ ) from sentry.constants import SentryAppStatus from sentry.models.auditlogentry import AuditLogEntry -from sentry.models.integrations.sentry_app_installation import SentryAppInstallation from sentry.models.organizationmember import OrganizationMember from sentry.models.servicehook import ServiceHook from sentry.sentry_apps.models.sentry_app import SentryApp +from sentry.sentry_apps.models.sentry_app_installation import SentryAppInstallation from sentry.silo.base import SiloMode from sentry.testutils.cases import APITestCase from sentry.testutils.helpers import with_feature diff --git a/tests/sentry/api/endpoints/test_sentry_apps.py b/tests/sentry/api/endpoints/test_sentry_apps.py index 0dec7b8e473cca..d8fbb1dc8e8612 100644 --- a/tests/sentry/api/endpoints/test_sentry_apps.py +++ b/tests/sentry/api/endpoints/test_sentry_apps.py @@ -14,11 +14,11 @@ from sentry import deletions from sentry.constants import SentryAppStatus from sentry.models.apitoken import ApiToken -from sentry.models.integrations.sentry_app_installation import SentryAppInstallation from sentry.models.integrations.sentry_app_installation_token import SentryAppInstallationToken from sentry.models.organization import Organization from sentry.models.organizationmember import OrganizationMember from sentry.sentry_apps.models.sentry_app import MASKED_VALUE, SentryApp +from sentry.sentry_apps.models.sentry_app_installation import SentryAppInstallation from sentry.silo.base import SiloMode from sentry.testutils.cases import APITestCase from sentry.testutils.helpers import Feature, with_feature diff --git a/tests/sentry/deletions/test_sentry_app.py b/tests/sentry/deletions/test_sentry_app.py index 6df4c829621073..f9df415061f2ee 100644 --- a/tests/sentry/deletions/test_sentry_app.py +++ b/tests/sentry/deletions/test_sentry_app.py @@ -3,8 +3,8 @@ from sentry import deletions from sentry.models.apiapplication import ApiApplication -from sentry.models.integrations.sentry_app_installation import SentryAppInstallation from sentry.sentry_apps.models.sentry_app import SentryApp +from sentry.sentry_apps.models.sentry_app_installation import SentryAppInstallation from sentry.testutils.cases import TestCase from sentry.testutils.silo import control_silo_test from sentry.users.models.user import User diff --git a/tests/sentry/deletions/test_sentry_app_installations.py b/tests/sentry/deletions/test_sentry_app_installations.py index 514701cc7e945f..b81e492f46113e 100644 --- a/tests/sentry/deletions/test_sentry_app_installations.py +++ b/tests/sentry/deletions/test_sentry_app_installations.py @@ -6,12 +6,12 @@ from sentry.deletions.tasks.hybrid_cloud import schedule_hybrid_cloud_foreign_key_jobs from sentry.models.apigrant import ApiGrant from sentry.models.apitoken import ApiToken -from sentry.models.integrations.sentry_app_installation import SentryAppInstallation from sentry.models.integrations.sentry_app_installation_for_provider import ( SentryAppInstallationForProvider, ) from sentry.models.servicehook import ServiceHook from sentry.sentry_apps.installations import SentryAppInstallationCreator +from sentry.sentry_apps.models.sentry_app_installation import SentryAppInstallation from sentry.silo.base import SiloMode from sentry.silo.safety import unguarded_write from sentry.testutils.cases import TestCase diff --git a/tests/sentry/deletions/test_sentry_installation_tokens.py b/tests/sentry/deletions/test_sentry_installation_tokens.py index 84ac80f753b566..1b5e34c6aeb76e 100644 --- a/tests/sentry/deletions/test_sentry_installation_tokens.py +++ b/tests/sentry/deletions/test_sentry_installation_tokens.py @@ -1,7 +1,7 @@ from sentry import deletions from sentry.models.apitoken import ApiToken -from sentry.models.integrations.sentry_app_installation import SentryAppInstallation from sentry.models.integrations.sentry_app_installation_token import SentryAppInstallationToken +from sentry.sentry_apps.models.sentry_app_installation import SentryAppInstallation from sentry.testutils.cases import TestCase from sentry.testutils.silo import control_silo_test diff --git a/tests/sentry/incidents/endpoints/test_organization_alert_rule_available_action_index.py b/tests/sentry/incidents/endpoints/test_organization_alert_rule_available_action_index.py index 7f38cb4a071efb..d5a276c29442f9 100644 --- a/tests/sentry/incidents/endpoints/test_organization_alert_rule_available_action_index.py +++ b/tests/sentry/incidents/endpoints/test_organization_alert_rule_available_action_index.py @@ -9,7 +9,8 @@ from sentry.integrations.models.organization_integration import OrganizationIntegration from sentry.integrations.pagerduty.utils import add_service from sentry.integrations.services.integration.serial import serialize_integration -from sentry.models.integrations import SentryAppComponent, SentryAppInstallation +from sentry.models.integrations import SentryAppComponent +from sentry.sentry_apps.models.sentry_app_installation import SentryAppInstallation from sentry.sentry_apps.services.app.serial import serialize_sentry_app_installation from sentry.silo.base import SiloMode from sentry.testutils.cases import APITestCase diff --git a/tests/sentry/integrations/vercel/test_integration.py b/tests/sentry/integrations/vercel/test_integration.py index 6e13732c22958a..fd0a349b16043d 100644 --- a/tests/sentry/integrations/vercel/test_integration.py +++ b/tests/sentry/integrations/vercel/test_integration.py @@ -10,7 +10,6 @@ from sentry.integrations.models.integration import Integration from sentry.integrations.models.organization_integration import OrganizationIntegration from sentry.integrations.vercel import VercelClient, VercelIntegrationProvider -from sentry.models.integrations.sentry_app_installation import SentryAppInstallation from sentry.models.integrations.sentry_app_installation_for_provider import ( SentryAppInstallationForProvider, ) @@ -18,6 +17,7 @@ from sentry.models.project import Project from sentry.models.projectkey import ProjectKey, ProjectKeyStatus from sentry.models.scheduledeletion import ScheduledDeletion +from sentry.sentry_apps.models.sentry_app_installation import SentryAppInstallation from sentry.silo.base import SiloMode from sentry.testutils.cases import IntegrationTestCase from sentry.testutils.silo import assume_test_silo_mode, control_silo_test diff --git a/tests/sentry/mediators/token_exchange/test_grant_exchanger.py b/tests/sentry/mediators/token_exchange/test_grant_exchanger.py index c408d0e399ff60..86ca3fee206305 100644 --- a/tests/sentry/mediators/token_exchange/test_grant_exchanger.py +++ b/tests/sentry/mediators/token_exchange/test_grant_exchanger.py @@ -7,8 +7,8 @@ from sentry.mediators.token_exchange.grant_exchanger import GrantExchanger from sentry.models.apiapplication import ApiApplication from sentry.models.apigrant import ApiGrant -from sentry.models.integrations.sentry_app_installation import SentryAppInstallation from sentry.sentry_apps.models.sentry_app import SentryApp +from sentry.sentry_apps.models.sentry_app_installation import SentryAppInstallation from sentry.sentry_apps.services.app import app_service from sentry.testutils.cases import TestCase from sentry.testutils.silo import control_silo_test diff --git a/tests/sentry/mediators/token_exchange/test_refresher.py b/tests/sentry/mediators/token_exchange/test_refresher.py index 8dfa2d4e747409..6937c12705e3a6 100644 --- a/tests/sentry/mediators/token_exchange/test_refresher.py +++ b/tests/sentry/mediators/token_exchange/test_refresher.py @@ -6,8 +6,8 @@ from sentry.mediators.token_exchange.refresher import Refresher from sentry.models.apiapplication import ApiApplication from sentry.models.apitoken import ApiToken -from sentry.models.integrations.sentry_app_installation import SentryAppInstallation from sentry.sentry_apps.models.sentry_app import SentryApp +from sentry.sentry_apps.models.sentry_app_installation import SentryAppInstallation from sentry.sentry_apps.services.app import app_service from sentry.testutils.cases import TestCase from sentry.testutils.silo import control_silo_test diff --git a/tests/sentry/models/test_apitoken.py b/tests/sentry/models/test_apitoken.py index b8a8c30b36261d..12a06e77a4fb93 100644 --- a/tests/sentry/models/test_apitoken.py +++ b/tests/sentry/models/test_apitoken.py @@ -7,8 +7,8 @@ from sentry.conf.server import SENTRY_SCOPE_HIERARCHY_MAPPING, SENTRY_SCOPES from sentry.hybridcloud.models import ApiTokenReplica from sentry.models.apitoken import ApiToken, NotSupported, PlaintextSecretAlreadyRead -from sentry.models.integrations.sentry_app_installation import SentryAppInstallation from sentry.models.integrations.sentry_app_installation_token import SentryAppInstallationToken +from sentry.sentry_apps.models.sentry_app_installation import SentryAppInstallation from sentry.silo.base import SiloMode from sentry.testutils.cases import TestCase from sentry.testutils.outbox import outbox_runner diff --git a/tests/sentry/models/test_sentryappinstallationtoken.py b/tests/sentry/models/test_sentryappinstallationtoken.py index c0963828847c9c..600094306c6241 100644 --- a/tests/sentry/models/test_sentryappinstallationtoken.py +++ b/tests/sentry/models/test_sentryappinstallationtoken.py @@ -1,10 +1,10 @@ from sentry.models.apiapplication import ApiApplication from sentry.models.apitoken import ApiToken -from sentry.models.integrations.sentry_app_installation import SentryAppInstallation from sentry.models.integrations.sentry_app_installation_for_provider import ( SentryAppInstallationForProvider, ) from sentry.models.integrations.sentry_app_installation_token import SentryAppInstallationToken +from sentry.sentry_apps.models.sentry_app_installation import SentryAppInstallation from sentry.testutils.cases import TestCase from sentry.testutils.silo import control_silo_test diff --git a/tests/sentry/ratelimits/utils/test_get_ratelimit_key.py b/tests/sentry/ratelimits/utils/test_get_ratelimit_key.py index a01c9733693628..498a52aabab53d 100644 --- a/tests/sentry/ratelimits/utils/test_get_ratelimit_key.py +++ b/tests/sentry/ratelimits/utils/test_get_ratelimit_key.py @@ -9,10 +9,10 @@ from sentry.auth.system import SystemToken from sentry.hybridcloud.models.apitokenreplica import ApiTokenReplica from sentry.models.apitoken import ApiToken -from sentry.models.integrations.sentry_app_installation import SentryAppInstallation from sentry.models.integrations.sentry_app_installation_token import SentryAppInstallationToken from sentry.ratelimits import get_rate_limit_config, get_rate_limit_key from sentry.ratelimits.config import RateLimitConfig +from sentry.sentry_apps.models.sentry_app_installation import SentryAppInstallation from sentry.testutils.cases import TestCase from sentry.testutils.silo import all_silo_test, assume_test_silo_mode_of from sentry.types.ratelimit import RateLimit, RateLimitCategory diff --git a/tests/sentry/sentry_apps/models/__init__.py b/tests/sentry/sentry_apps/models/__init__.py new file mode 100644 index 00000000000000..e69de29bb2d1d6 diff --git a/tests/sentry/models/test_sentryappinstallation.py b/tests/sentry/sentry_apps/models/test_sentryappinstallation.py similarity index 96% rename from tests/sentry/models/test_sentryappinstallation.py rename to tests/sentry/sentry_apps/models/test_sentryappinstallation.py index f41f2f844c7c10..34613eae73558f 100644 --- a/tests/sentry/models/test_sentryappinstallation.py +++ b/tests/sentry/sentry_apps/models/test_sentryappinstallation.py @@ -2,8 +2,8 @@ import sentry.hybridcloud.rpc.caching as caching_module from sentry.models.apiapplication import ApiApplication -from sentry.models.integrations.sentry_app_installation import SentryAppInstallation from sentry.sentry_apps.models.sentry_app import SentryApp +from sentry.sentry_apps.models.sentry_app_installation import SentryAppInstallation from sentry.testutils.cases import TestCase from sentry.testutils.silo import control_silo_test from sentry.types.region import get_region_for_organization diff --git a/tests/sentry/sentry_apps/services/test_app.py b/tests/sentry/sentry_apps/services/test_app.py index a5f83986104478..d2ba930ed8a110 100644 --- a/tests/sentry/sentry_apps/services/test_app.py +++ b/tests/sentry/sentry_apps/services/test_app.py @@ -1,5 +1,5 @@ from sentry.constants import SentryAppInstallationStatus -from sentry.models.integrations.sentry_app_installation import SentryAppInstallation +from sentry.sentry_apps.models.sentry_app_installation import SentryAppInstallation from sentry.sentry_apps.services.app import app_service from sentry.testutils.factories import Factories from sentry.testutils.pytest.fixtures import django_db_all diff --git a/tests/sentry/sentry_apps/test_sentry_app_creator.py b/tests/sentry/sentry_apps/test_sentry_app_creator.py index 961f42fd8ff8f5..35890fb83ab897 100644 --- a/tests/sentry/sentry_apps/test_sentry_app_creator.py +++ b/tests/sentry/sentry_apps/test_sentry_app_creator.py @@ -7,9 +7,9 @@ from sentry.models.apiapplication import ApiApplication from sentry.models.auditlogentry import AuditLogEntry from sentry.models.integrations.sentry_app_component import SentryAppComponent -from sentry.models.integrations.sentry_app_installation import SentryAppInstallation from sentry.sentry_apps.logic import SentryAppCreator from sentry.sentry_apps.models.sentry_app import SentryApp +from sentry.sentry_apps.models.sentry_app_installation import SentryAppInstallation from sentry.testutils.cases import TestCase from sentry.testutils.silo import control_silo_test from sentry.users.models.user import User diff --git a/tests/sentry/sentry_apps/test_sentry_app_installation_token_creator.py b/tests/sentry/sentry_apps/test_sentry_app_installation_token_creator.py index 67f912341a8c7e..50f1636fc2e90a 100644 --- a/tests/sentry/sentry_apps/test_sentry_app_installation_token_creator.py +++ b/tests/sentry/sentry_apps/test_sentry_app_installation_token_creator.py @@ -1,12 +1,12 @@ from datetime import UTC, datetime from unittest.mock import patch -from sentry.models.integrations.sentry_app_installation import SentryAppInstallation from sentry.models.integrations.sentry_app_installation_token import SentryAppInstallationToken from sentry.sentry_apps.installations import ( SentryAppInstallationCreator, SentryAppInstallationTokenCreator, ) +from sentry.sentry_apps.models.sentry_app_installation import SentryAppInstallation from sentry.testutils.cases import TestCase from sentry.testutils.silo import control_silo_test diff --git a/tests/sentry/tasks/test_sentry_apps.py b/tests/sentry/tasks/test_sentry_apps.py index 6f9e012e1398c6..5cc8ca5b653f1d 100644 --- a/tests/sentry/tasks/test_sentry_apps.py +++ b/tests/sentry/tasks/test_sentry_apps.py @@ -17,9 +17,9 @@ from sentry.integrations.request_buffer import IntegrationRequestBuffer from sentry.models.activity import Activity from sentry.models.auditlogentry import AuditLogEntry -from sentry.models.integrations.sentry_app_installation import SentryAppInstallation from sentry.models.rule import Rule from sentry.sentry_apps.models.sentry_app import SentryApp +from sentry.sentry_apps.models.sentry_app_installation import SentryAppInstallation from sentry.shared_integrations.exceptions import ClientError from sentry.tasks.post_process import post_process_group from sentry.tasks.sentry_apps import (