"""The node's subscription as a fact (netOrk #1111). The driver named ``no_subscription`` itself, comparing against "NotFound" while the API answers "notfound" -- so it never fired. It reports the subscription now; whether a missing one is a warning is the caller's decision. """ from __future__ import annotations import pytest from napalm_proxmox import ProxmoxDriver def _driver(subscription: dict) -> ProxmoxDriver: d = ProxmoxDriver("pve", "root@pam", "pw") d._get_node_subscription = lambda: subscription return d @pytest.mark.parametrize( "raw, status", [ ("notfound", "none"), ("NotFound", "none"), ("active", "active"), ("invalid", "invalid"), ("expired", "expired"), ("new", "unknown"), ("suspended", "unknown"), ], ) def test_the_api_status_as_a_license_status(raw, status): [lic] = _driver({"status": raw, "message": "There is no subscription key"}).get_licenses() assert lic["name"] == "pve-subscription" assert lic["status"] == status assert lic["detail"] == "There is no subscription key" def test_level_and_due_date_when_subscribed(): sub = { "status": "active", "productname": "Proxmox VE Community Subscription 1 CPU/year", "nextduedate": "2027-03-01", } [lic] = _driver(sub).get_licenses() assert lic["edition"] == "Proxmox VE Community Subscription 1 CPU/year" assert lic["expires"] == "2027-03-01" def test_an_unreadable_subscription_reports_nothing(): """``_get_node_subscription`` gives {} when the API call fails: no fact, not "none".""" assert _driver({}).get_licenses() == [] def test_no_warnings_of_its_own(): """lldpd, the updates and the subscription are facts the caller reads (get_packages, get_available_updates, get_licenses).""" assert not any("get_device_warnings" in vars(c) for c in ProxmoxDriver.__mro__[:-1] if c.__module__.startswith("napalm_proxmox"))