mirror of
https://github.com/moan0s/alertbot.git
synced 2024-10-01 06:25:35 -04:00
Add test for classification
This commit is contained in:
parent
896a536ae4
commit
68f8aaf79c
35
tests/test_alertbot.py
Normal file
35
tests/test_alertbot.py
Normal file
@ -0,0 +1,35 @@
|
||||
import unittest
|
||||
import alertbot
|
||||
import json
|
||||
|
||||
examples = [{"name": "Grafana Alert",
|
||||
"filepath": "../alert_examples/grafana_alert.json",
|
||||
"expected_response": "",
|
||||
"type": "grafana-alert"},
|
||||
{"name": "Grafana Resolved",
|
||||
"filepath": "../alert_examples/grafana_resolved.json",
|
||||
"expected_response": "",
|
||||
"type": "grafana-resolved"},
|
||||
{"name": "Uptime Kuma 503 Alert",
|
||||
"filepath": "../alert_examples/uptime-kuma-503-alert.json",
|
||||
"expected_response": "",
|
||||
"type": "uptime-kuma-alert"},
|
||||
{"name": "Prometheus Alert",
|
||||
"filepath": "../alert_examples/prometheus_alert.json",
|
||||
"expected_response": "",
|
||||
"type": "prometheus-alert"},
|
||||
]
|
||||
|
||||
|
||||
class ParseResponses(unittest.TestCase):
|
||||
def test_classification(self):
|
||||
for example in examples:
|
||||
print(f"Example: {example['name']}")
|
||||
with open(example["filepath"]) as file:
|
||||
alert_data = json.load(file)
|
||||
found_type = alertbot.find_alert_type(alert_data)
|
||||
self.assertEqual(found_type, example["type"])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
Loading…
Reference in New Issue
Block a user