Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/sentry/integrations/msteams/integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ class MsTeamsIntegration(IntegrationInstallation, IntegrationNotificationClient)
def get_client(self) -> MsTeamsClient:
return MsTeamsClient(self.model)

def get_config_data(self) -> Mapping[str, str]:
return {"installationType": self.model.metadata.get("installation_type", "")}

def send_notification(
self, target: IntegrationNotificationTarget, payload: AdaptiveCard
) -> None:
Expand Down
20 changes: 20 additions & 0 deletions tests/sentry/integrations/msteams/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,3 +226,23 @@ def test_send_notification_api_error(self, mock_send_card: MagicMock) -> None:
self.installation.send_notification(target=self.target, payload=payload)

assert str(e.value) == error_payload


@control_silo_test
class MsTeamsIntegrationConfigTest(TestCase):
def setUp(self) -> None:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: the other test classes in this file call super().setUp() here. It works without it because the fixtures are lazy, but worth keeping consistent.

self.integration = self.create_provider_integration(
provider="msteams", name="Microsoft Teams", metadata={}
)
self.installation = MsTeamsIntegration(self.integration, self.organization.id)

def test_config_data_team(self) -> None:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this and test_config_data_tenant only differ by the string. Could fold them into one test with both asserts.

self.integration.metadata["installation_type"] = "team"
assert self.installation.get_config_data()["installationType"] == "team"

def test_config_data_tenant(self) -> None:
self.integration.metadata["installation_type"] = "tenant"
assert self.installation.get_config_data()["installationType"] == "tenant"

def test_config_data_missing(self) -> None:
assert self.installation.get_config_data()["installationType"] == ""
Loading