def test_match_labels(self): """Check that we match labels properly.""" p = alertmanager.AlertmanagerPlugin() labels = {'foo': 'bar', 'bar': 'foo'} self.assertTrue(p.match_labels(labels, {})) self.assertTrue(p.match_labels(labels, {'foo': 'bar'})) self.assertFalse(p.match_labels(labels, {'foo': 'foo'}))
def test_all(self): """Test with some settings.""" with httmock.HTTMock(_alertmanager_mock): p = alertmanager.AlertmanagerPlugin({ 'api': self._API_URL, 'defcon': lambda _: 3, 'receiver': 'default', }) statuses = sorted(p.statuses().values()) status = statuses[0] self.assertEqual(status['title'], 'ExampleAlertAlwaysFiring') self.assertEqual(status['defcon'], 3)
def test_all(self): """Test with some settings.""" for api_url in self._API_URLS: with httmock.HTTMock(_alertmanager_mock): p = alertmanager.AlertmanagerPlugin({ 'api': api_url, 'defcon': lambda _: 3, 'receiver': 'default', }) statuses = sorted(p.statuses().values()) status = statuses[0] self.assertEqual(status['title'], 'ExampleAlertAlwaysFiring') self.assertEqual(status['defcon'], 3) # statuses[1] have wrong receiver, so it should raise an exeption with self.assertRaises(IndexError): statuses[1]
def test_base(self): """Basic test.""" p = alertmanager.AlertmanagerPlugin() self.assertFalse(p.statuses())