uptime-kuma-api/tests/uptime_kuma_test_case.py

40 lines
1 KiB
Python
Raw Normal View History

2022-08-02 23:47:56 +02:00
import unittest
2022-08-03 12:35:48 +02:00
2022-08-02 23:47:56 +02:00
from uptime_kuma_api import UptimeKumaApi
class UptimeKumaTestCase(unittest.TestCase):
api = None
2022-08-03 12:35:48 +02:00
password = "zS7zhQSc"
2022-08-02 23:47:56 +02:00
@classmethod
def setUpClass(cls):
cls.api = UptimeKumaApi("http://127.0.0.1:3001")
username = "testuser"
if cls.api.need_setup():
2022-08-03 12:35:48 +02:00
cls.api.setup(username, cls.password)
cls.api.login(username, cls.password)
2022-08-02 23:47:56 +02:00
@classmethod
def tearDownClass(cls):
cls.api.logout()
cls.api.disconnect()
def compare(self, superset, subset):
return subset.items() <= superset.items()
def find_by_id(self, objects, value, key="id"):
for obj in objects:
if obj[key] == value:
return obj
2022-08-03 12:35:48 +02:00
def add_monitor(self):
r = self.api.add_monitor(type="http", name="monitor 1", url="http://127.0.0.1")
monitor_id = r["monitorID"]
return monitor_id
def add_tag(self):
r = self.api.add_tag(name="tag 1", color="#ffffff")
tag_id = r["id"]
return tag_id