diff --git a/plugins/doc_fragments/uptime_kuma.py b/plugins/doc_fragments/uptime_kuma.py index 9ce9212..9bfaba5 100644 --- a/plugins/doc_fragments/uptime_kuma.py +++ b/plugins/doc_fragments/uptime_kuma.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright: (c) 2022, Lucas Held +# Copyright: (c) 2023, Lucas Held # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function diff --git a/plugins/module_utils/common.py b/plugins/module_utils/common.py index d65def8..dfc4ad4 100644 --- a/plugins/module_utils/common.py +++ b/plugins/module_utils/common.py @@ -1,4 +1,4 @@ -# Copyright: (c) 2022, Lucas Held +# Copyright: (c) 2023, Lucas Held from __future__ import absolute_import, division, print_function diff --git a/plugins/modules/docker_host.py b/plugins/modules/docker_host.py index 949331b..db23919 100644 --- a/plugins/modules/docker_host.py +++ b/plugins/modules/docker_host.py @@ -1,7 +1,7 @@ #!/usr/bin/python # -*- coding: utf-8 -*- -# Copyright: (c) 2022, Lucas Held +# Copyright: (c) 2023, Lucas Held # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function diff --git a/plugins/modules/docker_host_info.py b/plugins/modules/docker_host_info.py index 07882eb..8e6bbc4 100644 --- a/plugins/modules/docker_host_info.py +++ b/plugins/modules/docker_host_info.py @@ -1,7 +1,7 @@ #!/usr/bin/python # -*- coding: utf-8 -*- -# Copyright: (c) 2022, Lucas Held +# Copyright: (c) 2023, Lucas Held # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function diff --git a/plugins/modules/game_list_info.py b/plugins/modules/game_list_info.py new file mode 100644 index 0000000..4630d70 --- /dev/null +++ b/plugins/modules/game_list_info.py @@ -0,0 +1,116 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright: (c) 2023, Lucas Held +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + + +DOCUMENTATION = r''' +--- +extends_documentation_fragment: + - lucasheld.uptime_kuma.uptime_kuma + +module: game_list_info +author: Lucas Held (@lucasheld) +short_description: Retrieves facts about the games that are supported by the GameDig monitor type. +description: Retrieves facts about the games that are supported by the GameDig monitor type. +''' + +EXAMPLES = r''' +- name: get game list + lucasheld.uptime_kuma.game_list_info: + api_url: http://127.0.0.1:3001 + api_username: admin + api_password: secret123 + register: result +''' + +RETURN = r''' +game_list: + description: The game list + returned: always + type: complex + contains: + extra: + description: The extra value of the game. + returned: always + type: dict + sample: {} + keys: + description: The keys of the game. + returned: always + type: list + elements: str + sample: ["7d2d"] + options: + description: The options of the game. + returned: always + type: dict + sample: {"port": 26900, "port_query_offset": 1, "protocol": "valve"} + pretty: + description: The title of the game. + returned: always + type: str + sample: "7 Days to Die (2013)" +''' + +import traceback + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.lucasheld.uptime_kuma.plugins.module_utils.common import common_module_args +from ansible.module_utils.basic import missing_required_lib + +try: + from uptime_kuma_api import UptimeKumaApi + HAS_UPTIME_KUMA_API = True +except ImportError: + HAS_UPTIME_KUMA_API = False + + +def run(api, params, result): + result["game_list"] = api.get_game_list() + + +def main(): + module_args = dict() + module_args.update(common_module_args) + + module = AnsibleModule(module_args, supports_check_mode=True) + params = module.params + + if not HAS_UPTIME_KUMA_API: + module.fail_json(msg=missing_required_lib("uptime_kuma_api")) + + api = UptimeKumaApi(params["api_url"]) + api_token = params.get("api_token") + api_username = params.get("api_username") + api_password = params.get("api_password") + if api_token: + api.login_by_token(api_token) + elif api_username and api_password: + api.login(api_username, api_password) + else: + # autoLogin for enabled disableAuth + api.login() + + result = { + "changed": False + } + + try: + run(api, params, result) + + api.disconnect() + module.exit_json(**result) + except Exception: + api.disconnect() + error = traceback.format_exc() + module.fail_json(msg=error, **result) + + +if __name__ == '__main__': + main() diff --git a/plugins/modules/login.py b/plugins/modules/login.py index 2e6dcb3..7868a1b 100644 --- a/plugins/modules/login.py +++ b/plugins/modules/login.py @@ -1,7 +1,7 @@ #!/usr/bin/python # -*- coding: utf-8 -*- -# Copyright: (c) 2022, Lucas Held +# Copyright: (c) 2023, Lucas Held # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function diff --git a/plugins/modules/maintenance.py b/plugins/modules/maintenance.py index 0e1f467..56d67e6 100644 --- a/plugins/modules/maintenance.py +++ b/plugins/modules/maintenance.py @@ -1,7 +1,7 @@ #!/usr/bin/python # -*- coding: utf-8 -*- -# Copyright: (c) 2022, Lucas Held +# Copyright: (c) 2023, Lucas Held # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function diff --git a/plugins/modules/maintenance_info.py b/plugins/modules/maintenance_info.py index 61b38dc..43262ed 100644 --- a/plugins/modules/maintenance_info.py +++ b/plugins/modules/maintenance_info.py @@ -1,7 +1,7 @@ #!/usr/bin/python # -*- coding: utf-8 -*- -# Copyright: (c) 2022, Lucas Held +# Copyright: (c) 2023, Lucas Held # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function diff --git a/plugins/modules/monitor.py b/plugins/modules/monitor.py index 070a490..7c9f820 100644 --- a/plugins/modules/monitor.py +++ b/plugins/modules/monitor.py @@ -1,7 +1,7 @@ #!/usr/bin/python # -*- coding: utf-8 -*- -# Copyright: (c) 2022, Lucas Held +# Copyright: (c) 2023, Lucas Held # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function @@ -33,7 +33,7 @@ type: description: The type of the monitor. type: str - choices: ["http", "port", "ping", "keyword", "grpc-keyword", "dns", "docker", "push", "steam", "mqtt", "sqlserver", "postgres", "mysql", "radius"] + choices: ["http", "port", "ping", "keyword", "grpc-keyword", "dns", "docker", "push", "steam", "gamedig", "mqtt", "sqlserver", "postgres", "mysql", "mongodb", "radius", "redis"] interval: description: The heartbeat interval of the monitor. type: int @@ -148,6 +148,9 @@ hostname: description: The hostname of the monitor. type: str + packetSize: + description: The packet size of the monitor. + type: int port: description: The port of the monitor. type: int @@ -203,6 +206,9 @@ radiusCallingStationId: description: The radius calling station id of the monitor. type: str + game: + description: The game of the monitor. + type: str state: description: - Set to C(present) to create/update a monitor. @@ -289,6 +295,10 @@ def run(api, params, result): params["databaseConnectionString"] = "postgres://username:password@host:port/database" elif params["type"] == MonitorType.MYSQL: params["databaseConnectionString"] = "mysql://username:password@host:port/database" + elif params["type"] == MonitorType.MONGODB: + params["databaseConnectionString"] = "mongodb://username:password@host:port/database" + elif params["type"] == MonitorType.REDIS: + params["databaseConnectionString"] = "redis://user:password@host:port" if not params["port"]: if type == MonitorType.DNS: @@ -353,7 +363,7 @@ def main(): module_args = dict( id=dict(type="int"), name=dict(type="str"), - type=dict(type="str", choices=["http", "port", "ping", "keyword", "dns", "docker", "push", "steam", "mqtt", "sqlserver", "postgres", "mysql", "radius"]), + type=dict(type="str", choices=["http", "port", "ping", "keyword", "grpc-keyword", "dns", "docker", "push", "steam", "gamedig", "mqtt", "sqlserver", "postgres", "mysql", "mongodb", "radius", "redis"]), interval=dict(type="int"), retryInterval=dict(type="int"), resendInterval=dict(type="int"), @@ -397,6 +407,9 @@ def main(): # PORT, PING, DNS, STEAM, MQTT hostname=dict(type="str"), + # PING + packetSize=dict(type="int"), + # PORT, DNS, STEAM, MQTT, RADIUS port=dict(type="int"), @@ -410,8 +423,10 @@ def main(): mqttTopic=dict(type="str"), mqttSuccessMessage=dict(type="str"), - # SQLSERVER, POSTGRES, MYSQL + # SQLSERVER, POSTGRES, MYSQL, MONGODB, REDIS databaseConnectionString=dict(type="str"), + + # SQLSERVER, POSTGRES, MYSQL databaseQuery=dict(type="str"), # DOCKER @@ -426,6 +441,9 @@ def main(): radiusCalledStationId=dict(type="str"), radiusCallingStationId=dict(type="str"), + # GAMEDIG + game=dict(type="str"), + state=dict(type="str", default="present", choices=["present", "absent", "paused", "resumed"]) ) module_args.update(common_module_args) diff --git a/plugins/modules/monitor_info.py b/plugins/modules/monitor_info.py index 9d9d68b..2989dbb 100644 --- a/plugins/modules/monitor_info.py +++ b/plugins/modules/monitor_info.py @@ -1,7 +1,7 @@ #!/usr/bin/python # -*- coding: utf-8 -*- -# Copyright: (c) 2022, Lucas Held +# Copyright: (c) 2023, Lucas Held # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function @@ -277,6 +277,61 @@ returned: always type: str sample: None + radiusCalledStationId: + description: The radiusCalledStationId of the monitor. + returned: always + type: str + sample: None + radiusCallingStationId: + description: The radiusCallingStationId of the monitor. + returned: always + type: str + sample: None + radiusUsername: + description: The radiusUsername of the monitor. + returned: always + type: str + sample: None + radiusPassword: + description: The radiusPassword of the monitor. + returned: always + type: str + sample: None + radiusSecret: + description: The radiusSecret of the monitor. + returned: always + type: str + sample: None + resendInterval: + description: The resendInterval of the monitor. + returned: always + type: int + sample: 0 + packetSize: + description: The packetSize of the monitor. + returned: always + type: int + sample: 56 + includeSensitiveData: + description: The includeSensitiveData of the monitor. + returned: always + type: bool + sample: True + game: + description: The game of the monitor. + returned: always + type: str + sample: '7d2d' + docker_host: + description: The docker_host of the monitor. + returned: always + type: int + sample: None + docker_container: + description: The docker_container of the monitor. + returned: always + type: str + sample: "" ''' import traceback diff --git a/plugins/modules/monitor_tag.py b/plugins/modules/monitor_tag.py index e145c23..ca02b3c 100644 --- a/plugins/modules/monitor_tag.py +++ b/plugins/modules/monitor_tag.py @@ -1,7 +1,7 @@ #!/usr/bin/python # -*- coding: utf-8 -*- -# Copyright: (c) 2022, Lucas Held +# Copyright: (c) 2023, Lucas Held # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function diff --git a/plugins/modules/notification.py b/plugins/modules/notification.py index eb2ecb5..29f0acc 100644 --- a/plugins/modules/notification.py +++ b/plugins/modules/notification.py @@ -1,7 +1,7 @@ #!/usr/bin/python # -*- coding: utf-8 -*- -# Copyright: (c) 2022, Lucas Held +# Copyright: (c) 2023, Lucas Held # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function diff --git a/plugins/modules/notification_info.py b/plugins/modules/notification_info.py index b721c7c..7602c4f 100644 --- a/plugins/modules/notification_info.py +++ b/plugins/modules/notification_info.py @@ -1,7 +1,7 @@ #!/usr/bin/python # -*- coding: utf-8 -*- -# Copyright: (c) 2022, Lucas Held +# Copyright: (c) 2023, Lucas Held # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function diff --git a/plugins/modules/proxy.py b/plugins/modules/proxy.py index 6e0dd2c..cd1a8cd 100644 --- a/plugins/modules/proxy.py +++ b/plugins/modules/proxy.py @@ -1,7 +1,7 @@ #!/usr/bin/python # -*- coding: utf-8 -*- -# Copyright: (c) 2022, Lucas Held +# Copyright: (c) 2023, Lucas Held # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function diff --git a/plugins/modules/proxy_info.py b/plugins/modules/proxy_info.py index 3df3cbe..2ad2869 100644 --- a/plugins/modules/proxy_info.py +++ b/plugins/modules/proxy_info.py @@ -1,7 +1,7 @@ #!/usr/bin/python # -*- coding: utf-8 -*- -# Copyright: (c) 2022, Lucas Held +# Copyright: (c) 2023, Lucas Held # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function diff --git a/plugins/modules/settings.py b/plugins/modules/settings.py index 913e3ba..47f02f8 100644 --- a/plugins/modules/settings.py +++ b/plugins/modules/settings.py @@ -1,7 +1,7 @@ #!/usr/bin/python # -*- coding: utf-8 -*- -# Copyright: (c) 2022, Lucas Held +# Copyright: (c) 2023, Lucas Held # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function diff --git a/plugins/modules/settings_info.py b/plugins/modules/settings_info.py index 3136a06..4eec5ab 100644 --- a/plugins/modules/settings_info.py +++ b/plugins/modules/settings_info.py @@ -1,7 +1,7 @@ #!/usr/bin/python # -*- coding: utf-8 -*- -# Copyright: (c) 2022, Lucas Held +# Copyright: (c) 2023, Lucas Held # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function diff --git a/plugins/modules/setup.py b/plugins/modules/setup.py index a99c306..49d01d1 100644 --- a/plugins/modules/setup.py +++ b/plugins/modules/setup.py @@ -1,7 +1,7 @@ #!/usr/bin/python # -*- coding: utf-8 -*- -# Copyright: (c) 2022, Lucas Held +# Copyright: (c) 2023, Lucas Held # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function diff --git a/plugins/modules/status_page.py b/plugins/modules/status_page.py index 257498c..fc5254d 100644 --- a/plugins/modules/status_page.py +++ b/plugins/modules/status_page.py @@ -1,7 +1,7 @@ #!/usr/bin/python # -*- coding: utf-8 -*- -# Copyright: (c) 2022, Lucas Held +# Copyright: (c) 2023, Lucas Held # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function @@ -44,6 +44,9 @@ description: The domain name list of the status page. type: list elements: "str" + googleAnalyticsId: + description: The Google Analytics ID of the status page. + type: str customCSS: description: The custom CSS of the status page. type: str @@ -227,6 +230,7 @@ def main(): published=dict(type="bool"), showTags=dict(type="bool"), domainNameList=dict(type="list", elements="str"), + googleAnalyticsId=dict(type="str"), customCSS=dict(type="str"), footerText=dict(type="str"), showPoweredBy=dict(type="bool"), diff --git a/plugins/modules/status_page_info.py b/plugins/modules/status_page_info.py index cb26049..a5aa0e6 100644 --- a/plugins/modules/status_page_info.py +++ b/plugins/modules/status_page_info.py @@ -1,7 +1,7 @@ #!/usr/bin/python # -*- coding: utf-8 -*- -# Copyright: (c) 2022, Lucas Held +# Copyright: (c) 2023, Lucas Held # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function @@ -81,17 +81,22 @@ type: bool sample: False domainNameList: - description: The domainNameList of the status page. + description: The domain name list of the status page. returned: always type: list sample: [] + googleAnalyticsId: + description: The Google Analytics ID of the status page. + returned: always + type: str + sample: None customCSS: - description: The customCS of the status page. + description: The custom CSS of the status page. returned: always type: str sample: None footerText: - description: The footerText of the status page. + description: The footer text of the status page. returned: always type: str sample: None diff --git a/plugins/modules/tag.py b/plugins/modules/tag.py index f667382..0b22291 100644 --- a/plugins/modules/tag.py +++ b/plugins/modules/tag.py @@ -1,7 +1,7 @@ #!/usr/bin/python # -*- coding: utf-8 -*- -# Copyright: (c) 2022, Lucas Held +# Copyright: (c) 2023, Lucas Held # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function @@ -52,6 +52,15 @@ color: "#ff0000" state: present +- name: Edit tag + lucasheld.uptime_kuma.tag: + api_url: http://127.0.0.1:3001 + api_username: admin + api_password: secret123 + name: Tag 1 + color: "#ffffff" + state: present + - name: Remove tag lucasheld.uptime_kuma.tag: api_url: http://127.0.0.1:3001 @@ -67,7 +76,8 @@ import traceback from ansible.module_utils.basic import AnsibleModule, missing_required_lib -from ansible_collections.lucasheld.uptime_kuma.plugins.module_utils.common import common_module_args, get_tag_by_name +from ansible_collections.lucasheld.uptime_kuma.plugins.module_utils.common import common_module_args, get_tag_by_name, \ + clear_params, object_changed, clear_unset_params try: from uptime_kuma_api import UptimeKumaApi @@ -78,6 +88,8 @@ def run(api, params, result): state = params["state"] + options = clear_params(params) + options = clear_unset_params(options) if params["id"]: tag = api.get_tag(params["id"]) @@ -86,8 +98,13 @@ def run(api, params, result): if state == "present": if not tag: - api.add_tag(params["name"], params["color"]) + api.add_tag(**options) result["changed"] = True + else: + changed_keys = object_changed(tag, options) + if changed_keys: + api.edit_tag(tag["id"], **options) + result["changed"] = True elif state == "absent": if tag: api.delete_tag(tag["id"]) diff --git a/plugins/modules/tag_info.py b/plugins/modules/tag_info.py index 87aefdd..9ae6c2a 100644 --- a/plugins/modules/tag_info.py +++ b/plugins/modules/tag_info.py @@ -1,7 +1,7 @@ #!/usr/bin/python # -*- coding: utf-8 -*- -# Copyright: (c) 2022, Lucas Held +# Copyright: (c) 2023, Lucas Held # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function diff --git a/run_tests.sh b/run_tests.sh index a5e0a20..9d4bdf3 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -26,7 +26,7 @@ if [ $version ] && [ "$version" != "all" ] then versions=("$version") else - versions=(1.19.5 1.18.5 1.17.1) + versions=(1.20.0 1.19.6 1.18.5 1.17.1) fi unit_targets="" diff --git a/tests/integration/targets/game_list_info/tasks/main.yml b/tests/integration/targets/game_list_info/tasks/main.yml new file mode 100644 index 0000000..f704484 --- /dev/null +++ b/tests/integration/targets/game_list_info/tasks/main.yml @@ -0,0 +1,5 @@ +- name: get game list + lucasheld.uptime_kuma.game_list_info: + api_url: http://127.0.0.1:3001 + api_username: admin + api_password: secret123 diff --git a/tests/unit/plugins/module_utils/module_test_case.py b/tests/unit/plugins/module_utils/module_test_case.py index 374e25b..ed72840 100644 --- a/tests/unit/plugins/module_utils/module_test_case.py +++ b/tests/unit/plugins/module_utils/module_test_case.py @@ -2,7 +2,7 @@ import copy import unittest import tempfile -from uptime_kuma_api import UptimeKumaApi, Event, MonitorType, DockerType, UptimeKumaException, MaintenanceStrategy +from uptime_kuma_api import UptimeKumaApi, MonitorType, DockerType, UptimeKumaException, MaintenanceStrategy from packaging.version import parse as parse_version diff --git a/tests/unit/plugins/module_utils/test_game_list_info.py b/tests/unit/plugins/module_utils/test_game_list_info.py new file mode 100644 index 0000000..dd0d853 --- /dev/null +++ b/tests/unit/plugins/module_utils/test_game_list_info.py @@ -0,0 +1,25 @@ +from packaging.version import parse as parse_version +from .module_test_case import ModuleTestCase +import plugins.modules.game_list_info as module + + +class TestGameListInfo(ModuleTestCase): + def setUp(self): + super(TestGameListInfo, self).setUp() + + if parse_version(self.api.version) < parse_version("1.20"): + super(TestGameListInfo, self).tearDown() + self.skipTest("Unsupported in this Uptime Kuma version") + + self.params = { + "api_url": "http://127.0.0.1:3001", + "api_username": None, + "api_password": None, + "api_token": None + } + + def test_game_list(self): + result = self.run_module(module, self.params) + + self.assertFalse(result["changed"]) + self.assertTrue("keys" in result["game_list"][0]) diff --git a/tests/unit/plugins/module_utils/test_monitor.py b/tests/unit/plugins/module_utils/test_monitor.py index d1f12ce..c669ba2 100644 --- a/tests/unit/plugins/module_utils/test_monitor.py +++ b/tests/unit/plugins/module_utils/test_monitor.py @@ -48,6 +48,7 @@ def setUp(self): "grpcBody": None, "grpcMetadata": None, "hostname": None, + "packetSize": None, "port": None, "dns_resolve_server": None, "dns_resolve_type": None, @@ -65,6 +66,7 @@ def setUp(self): "radiusSecret": None, "radiusCalledStationId": None, "radiusCallingStationId": None, + "game": None, "state": "present" } diff --git a/tests/unit/plugins/module_utils/test_status_page.py b/tests/unit/plugins/module_utils/test_status_page.py index 6a7fefb..74b9324 100644 --- a/tests/unit/plugins/module_utils/test_status_page.py +++ b/tests/unit/plugins/module_utils/test_status_page.py @@ -19,6 +19,7 @@ def setUp(self): "published": None, "showTags": None, "domainNameList": None, + "googleAnalyticsId": None, "customCSS": None, "footerText": None, "showPoweredBy": None, @@ -41,6 +42,7 @@ def test_status_page(self): "published": True, "showTags": False, "domainNameList": [], + "googleAnalyticsId": None, "customCSS": "", "footerText": None, "showPoweredBy": False, @@ -68,6 +70,8 @@ def test_status_page(self): self.assertEqual(status_page["published"], self.params["published"]) self.assertEqual(status_page["showTags"], self.params["showTags"]) self.assertEqual(status_page["domainNameList"], self.params["domainNameList"]) + if parse_version(self.api.version) >= parse_version("1.20"): + self.assertEqual(status_page["googleAnalyticsId"], self.params["googleAnalyticsId"]) self.assertEqual(status_page["customCSS"], self.params["customCSS"]) self.assertEqual(status_page["footerText"], self.params["footerText"]) self.assertEqual(status_page["showPoweredBy"], self.params["showPoweredBy"]) diff --git a/tests/unit/plugins/module_utils/test_tag.py b/tests/unit/plugins/module_utils/test_tag.py index 8675473..d28c177 100644 --- a/tests/unit/plugins/module_utils/test_tag.py +++ b/tests/unit/plugins/module_utils/test_tag.py @@ -1,3 +1,5 @@ +from packaging.version import parse as parse_version + from .module_test_case import ModuleTestCase import plugins.modules.tag as module from plugins.module_utils.common import get_tag_by_name @@ -29,11 +31,18 @@ def test_tag(self): tag = get_tag_by_name(self.api, self.params["name"]) self.assertEqual(tag["color"], self.params["color"]) - # add tag by id - tag_id = tag["id"] - self.params.update({ - "id": tag_id - }) + if parse_version(self.api.version) >= parse_version("1.20"): + # edit tag by id + tag_id = tag["id"] + self.params.update({ + "id": tag_id, + "color": "#000000" + }) + result = self.run_module(module, self.params) + self.assertTrue(result["changed"]) + tag = self.api.get_tag(tag_id) + self.assertEqual(tag["color"], self.params["color"]) + result = self.run_module(module, self.params) self.assertFalse(result["changed"])