From a17977b22593210fd2ecd39380aa29e5eb608827 Mon Sep 17 00:00:00 2001 From: Fredrik Jonsson <frjo@xdeb.org> Date: Thu, 25 Jun 2020 14:03:56 +0200 Subject: [PATCH] Update test for custom slack channel, add test for multiple custom channels. --- hypha/apply/activity/tests/test_messaging.py | 24 ++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/hypha/apply/activity/tests/test_messaging.py b/hypha/apply/activity/tests/test_messaging.py index 73e9ab5ad..6aa2fe27c 100644 --- a/hypha/apply/activity/tests/test_messaging.py +++ b/hypha/apply/activity/tests/test_messaging.py @@ -380,7 +380,7 @@ class TestSlackAdapter(AdapterMixin, TestCase): SLACK_DESTINATION_ROOM=target_room, ) @responses.activate - def test_round_slack_channel(self): + def test_fund_custom_slack_channel(self): responses.add(responses.POST, self.target_url, status=200, body='OK') submission = ApplicationSubmissionFactory(round__parent__slack_channel='dummy') adapter = SlackAdapter() @@ -390,7 +390,27 @@ class TestSlackAdapter(AdapterMixin, TestCase): self.assertDictEqual( json.loads(responses.calls[0].request.body), { - 'room': [self.target_room, '#dummy'], + 'room': ['#dummy'], + 'message': message, + } + ) + + @override_settings( + SLACK_DESTINATION_URL=target_url, + SLACK_DESTINATION_ROOM=target_room, + ) + @responses.activate + def test_fund_multiple_custom_slack_channel(self): + responses.add(responses.POST, self.target_url, status=200, body='OK') + submission = ApplicationSubmissionFactory(round__parent__slack_channel='dummy1, dummy2') + adapter = SlackAdapter() + message = 'my message' + adapter.send_message(message, '', source=submission) + self.assertEqual(len(responses.calls), 1) + self.assertDictEqual( + json.loads(responses.calls[0].request.body), + { + 'room': ['#dummy1', '#dummy2'], 'message': message, } ) -- GitLab