-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into james/rm_pgadmin
- Loading branch information
Showing
5 changed files
with
154 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,12 +6,26 @@ | |
from django.test import RequestFactory, TestCase | ||
from requests import RequestException | ||
|
||
from meshapi.models import Member | ||
from meshapi.models import Building, Install, Member | ||
from meshapi.serializers import MemberSerializer | ||
from meshapi.tests.sample_data import sample_building, sample_install, sample_member | ||
from meshapi.util.admin_notifications import notify_administrators_of_data_issue | ||
|
||
|
||
class TestSlackNotification(TestCase): | ||
def setUp(self): | ||
self.sample_install_copy = sample_install.copy() | ||
self.building_1 = Building(**sample_building) | ||
self.building_1.save() | ||
self.sample_install_copy["building"] = self.building_1 | ||
|
||
self.sample_member = Member(**sample_member) | ||
self.sample_member.save() | ||
self.sample_install_copy["member"] = self.sample_member | ||
|
||
self.install = Install(**self.sample_install_copy) | ||
self.install.save() | ||
|
||
@requests_mock.Mocker() | ||
@patch("meshapi.util.admin_notifications.SLACK_ADMIN_NOTIFICATIONS_WEBHOOK_URL", "https://mock-slack-url") | ||
def test_slack_notification_for_name_change(self, requests_mocker): | ||
|
@@ -23,6 +37,9 @@ def test_slack_notification_for_name_change(self, requests_mocker): | |
) | ||
member.save() | ||
|
||
self.install.member = member | ||
self.install.save() | ||
|
||
rf = RequestFactory() | ||
mock_join_form_request = rf.post("https://mock-meshdb-url.example/join-form/") | ||
|
||
|
@@ -56,7 +73,12 @@ def test_slack_notification_for_name_change(self, requests_mocker): | |
' "all_phone_numbers": [\n' | ||
' "+1 212-555-5555"\n' | ||
" ],\n" | ||
' "installs": [],\n' | ||
' "installs": [\n' | ||
" {\n" | ||
f' "id": "{self.install.id}",\n' | ||
f' "install_number": {self.install.install_number}\n' | ||
" }\n" | ||
" ],\n" | ||
' "name": "Stacy Maidenname",\n' | ||
' "primary_email_address": "[email protected]",\n' | ||
' "stripe_email_address": null,\n' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters