From 655e71d487537aeea3dda7fe14da157f25d47a94 Mon Sep 17 00:00:00 2001 From: lucasheld Date: Wed, 3 Aug 2022 12:37:37 +0200 Subject: [PATCH] login by token in tests to fix the rate limit issue --- tests/uptime_kuma_test_case.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/tests/uptime_kuma_test_case.py b/tests/uptime_kuma_test_case.py index 4013613..bb90fc3 100644 --- a/tests/uptime_kuma_test_case.py +++ b/tests/uptime_kuma_test_case.py @@ -3,17 +3,27 @@ import unittest from uptime_kuma_api import UptimeKumaApi +token = None + + class UptimeKumaTestCase(unittest.TestCase): api = None + url = "http://127.0.0.1:3001" + username = "testuser" password = "zS7zhQSc" @classmethod def setUpClass(cls): - cls.api = UptimeKumaApi("http://127.0.0.1:3001") - username = "testuser" - if cls.api.need_setup(): - cls.api.setup(username, cls.password) - cls.api.login(username, cls.password) + cls.api = UptimeKumaApi(cls.url) + + global token + if not token: + if cls.api.need_setup(): + cls.api.setup(cls.username, cls.password) + r = cls.api.login(cls.username, cls.password) + token = r["token"] + + cls.api.login_by_token(token) @classmethod def tearDownClass(cls):