def slack(payload): """Send a Slack notification using the provided payload.""" try: notification = SlackNotification(payload) notification.send(fail_silently=False) except RequestException as exc: slack.retry( countdown=2**slack.request.retries * 30 + randint(0, 30), args=[payload], exc=exc, )
class TestSlackNotifications(TestCase): """Check that Slack notifications send to the correct endpoint.""" def setUp(self): payload = {'text': 'Test'} self.slack = SlackNotification(payload) @patch('requests.post') def test_send(self, mock_post): """Sending should post the payload to the endpoint.""" endpoint = self.slack.endpoint data = json.dumps(self.slack.payload) self.slack.send() mock_post.assert_called_with(endpoint, data=data)
def setUp(self): payload = {'text': 'Test'} self.slack = SlackNotification(payload)
def slack(payload): """Send a Slack notification using the provided payload.""" notification = SlackNotification(payload) notification.send()
def setUp(self): payload = {"text": "Test"} self.slack = SlackNotification(payload)