diff --git a/tests/test_avg_ping.py b/tests/test_avg_ping.py new file mode 100644 index 0000000..fc9b3be --- /dev/null +++ b/tests/test_avg_ping.py @@ -0,0 +1,13 @@ +import unittest + +from uptime_kuma_test_case import UptimeKumaTestCase + + +class TestAvgPing(UptimeKumaTestCase): + def test_avg_ping(self): + self.add_monitor() + self.api.avg_ping() + + +if __name__ == '__main__': + unittest.main() diff --git a/tests/test_database.py b/tests/test_database.py new file mode 100644 index 0000000..640b9ce --- /dev/null +++ b/tests/test_database.py @@ -0,0 +1,16 @@ +import unittest + +from uptime_kuma_test_case import UptimeKumaTestCase + + +class TestDatabase(UptimeKumaTestCase): + def test_get_database_size(self): + r = self.api.get_database_size() + self.assertIn("size", r) + + def test_shrink_database(self): + self.api.shrink_database() + + +if __name__ == '__main__': + unittest.main() diff --git a/tests/test_monitor.py b/tests/test_monitor.py index 8cc7d91..f438759 100644 --- a/tests/test_monitor.py +++ b/tests/test_monitor.py @@ -49,6 +49,9 @@ class TestMonitor(UptimeKumaTestCase): r = self.api.resume_monitor(monitor_id) self.assertEqual(r["msg"], "Resumed Successfully.") + # get monitor beats + self.api.get_monitor_beats(monitor_id, 6) + # delete monitor r = self.api.delete_monitor(monitor_id) self.assertEqual(r["msg"], "Deleted Successfully.") diff --git a/tests/test_settings.py b/tests/test_settings.py index 2777d69..39179af 100644 --- a/tests/test_settings.py +++ b/tests/test_settings.py @@ -1,4 +1,5 @@ import unittest +import json from uptime_kuma_test_case import UptimeKumaTestCase @@ -13,6 +14,32 @@ class TestSettings(UptimeKumaTestCase): settings = self.api.get_settings() self.assertEqual(settings["checkUpdate"], expected_check_update) + def test_change_password(self): + new_password = "321terces" + + # change password + r = self.api.change_password(self.password, new_password) + self.assertEqual(r["msg"], "Password has been updated successfully.") + + # check login + r = self.api.login(self.username, new_password) + self.assertIn("token", r) + + # restore password + r = self.api.change_password(new_password, self.password) + self.assertEqual(r["msg"], "Password has been updated successfully.") + + def test_upload_backup(self): + data = { + "version": "1.17.1", + "notificationList": [], + "monitorList": [], + "proxyList": [] + } + data_str = json.dumps(data) + r = self.api.upload_backup(data_str, "overwrite") + self.assertEqual(r["msg"], "Backup successfully restored.") + if __name__ == '__main__': unittest.main() diff --git a/tests/test_uptime.py b/tests/test_uptime.py new file mode 100644 index 0000000..c2dc23a --- /dev/null +++ b/tests/test_uptime.py @@ -0,0 +1,13 @@ +import unittest + +from uptime_kuma_test_case import UptimeKumaTestCase + + +class TestUptime(UptimeKumaTestCase): + def test_uptime(self): + self.add_monitor() + self.api.uptime() + + +if __name__ == '__main__': + unittest.main() diff --git a/uptime_kuma_api/api.py b/uptime_kuma_api/api.py index 160e5aa..866d71d 100644 --- a/uptime_kuma_api/api.py +++ b/uptime_kuma_api/api.py @@ -788,7 +788,7 @@ class UptimeKumaApi(object): "newPassword": new_password, }) - def upload_backup(self, json_data, import_handle: str): + def upload_backup(self, json_data, import_handle: str = "skip"): if import_handle not in ["overwrite", "skip", "keep"]: raise ValueError() return self._call('uploadBackup', (json_data, import_handle))