Exemple #1
0
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,
        )
Exemple #2
0
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)
Exemple #3
0
 def setUp(self):
     payload = {'text': 'Test'}
     self.slack = SlackNotification(payload)
Exemple #4
0
def slack(payload):
    """Send a Slack notification using the provided payload."""
    notification = SlackNotification(payload)
    notification.send()
Exemple #5
0
 def setUp(self):
     payload = {"text": "Test"}
     self.slack = SlackNotification(payload)