|
9 | 9 | from sentry.integrations.services.integration.serial import serialize_integration |
10 | 10 | from sentry.silo.base import SiloMode |
11 | 11 | from sentry.testutils.cases import APITestCase |
| 12 | +from sentry.testutils.helpers.options import override_options |
12 | 13 | from sentry.testutils.silo import assume_test_silo_mode |
| 14 | +from sentry.viewer_context import ActorType, get_viewer_context |
13 | 15 |
|
14 | 16 | from . import EXAMPLE_PAYLOAD, get_integration, link_group |
15 | 17 |
|
@@ -94,6 +96,27 @@ def test_post_update_status(self, mock_sync: MagicMock) -> None: |
94 | 96 | }, |
95 | 97 | ) |
96 | 98 |
|
| 99 | + @override_options({"viewer-context.enabled": True}) |
| 100 | + @patch.object(JiraServerIntegration, "sync_status_inbound") |
| 101 | + def test_post_update_status_sets_viewer_context(self, mock_sync: MagicMock) -> None: |
| 102 | + captured_contexts: list = [] |
| 103 | + |
| 104 | + def capture_context(*args: object, **kwargs: object) -> None: |
| 105 | + captured_contexts.append(get_viewer_context()) |
| 106 | + |
| 107 | + mock_sync.side_effect = capture_context |
| 108 | + |
| 109 | + project = self.create_project() |
| 110 | + self.create_group(project=project) |
| 111 | + |
| 112 | + self.get_success_response(self.jwt_token, **EXAMPLE_PAYLOAD) |
| 113 | + |
| 114 | + assert len(captured_contexts) == 1 |
| 115 | + vc = captured_contexts[0] |
| 116 | + assert vc is not None |
| 117 | + assert vc.organization_id == self.organization.id |
| 118 | + assert vc.actor_type == ActorType.INTEGRATION |
| 119 | + |
97 | 120 | @responses.activate |
98 | 121 | def test_post_update_status_token_error(self) -> None: |
99 | 122 | responses.add( |
|
0 commit comments