fix delete tag test and fix compare object

This commit is contained in:
lucasheld 2022-08-03 16:56:38 +02:00
parent 655e71d487
commit f433fe4416
5 changed files with 21 additions and 12 deletions

View file

@ -1,14 +1,18 @@
from uptime_kuma_api import params_map_notification_providers, notification_provider_options, params_map_notification_provider_options, convert_from_socket
from uptime_kuma_api import notification_provider_options
for provider_sock, provider_py in params_map_notification_providers.items():
options = notification_provider_options[provider_sock]
tmp = options
params_map = params_map_notification_provider_options[provider_py]
options = convert_from_socket(params_map, options)
def build_providers():
providers = []
for provider_enum in notification_provider_options:
provider = provider_enum.__dict__["_value_"]
providers.append(provider)
return providers
for provider in build_providers():
options = notification_provider_options[provider]
for option in options:
print(f'{option}:')
print(f' description: {provider_py} provider option.')
print(f' returned: if type is {provider_py}')
print(f' description: {provider} provider option.')
print(f' returned: if type is {provider}')
print(' type: str')

View file

@ -22,11 +22,16 @@ class TestProxy(UptimeKumaTestCase):
proxy = self.api.get_proxy(proxy_id)
self.compare(proxy, expected_proxy)
# get proxies
proxies = self.api.get_proxies()
proxy = self.find_by_id(proxies, proxy_id)
self.assertIsNotNone(proxy)
self.compare(proxy, expected_proxy)
# edit proxy
expected_proxy["protocol"] = "https"
expected_proxy["host"] = "127.0.0.2"
expected_proxy["port"] = 8888
expected_proxy["active"] = False
r = self.api.edit_proxy(proxy_id, **expected_proxy)
self.assertEqual(r["msg"], "Saved")
proxy = self.api.get_proxy(proxy_id)

View file

@ -30,7 +30,7 @@ class TestTag(UptimeKumaTestCase):
r = self.api.delete_tag(tag_id)
self.assertEqual(r["msg"], "Deleted Successfully.")
with self.assertRaises(UptimeKumaException):
self.api.get_proxy(tag_id)
self.api.get_tag(tag_id)
if __name__ == '__main__':

View file

@ -31,7 +31,7 @@ class UptimeKumaTestCase(unittest.TestCase):
cls.api.disconnect()
def compare(self, superset, subset):
return subset.items() <= superset.items()
self.assertTrue(subset.items() <= superset.items())
def find_by_id(self, objects, value, key="id"):
for obj in objects:

View file

@ -1,5 +1,5 @@
__title__ = "uptime_kuma_api"
__version__ = "0.0.6"
__version__ = "0.0.7"
__author__ = "Lucas Held"
__license__ = "MIT"
__copyright__ = "Copyright 2022 Lucas Held"