feat!: report the package proxy as a fact; no warnings of its own (0.9.0)
CI / test (3.10) (push) Successful in 34s
CI / test (3.11) (push) Successful in 32s
CI / test (3.12) (push) Successful in 29s
CI / test (3.10) (pull_request) Successful in 25s
CI / test (3.11) (pull_request) Successful in 23s
CI / test (3.12) (pull_request) Successful in 25s

get_device_warnings decided two things for the application: that any
pending update is a warning (it re-read the updates for that), and
whether apt's proxy is the one the application's setting wants, which
it was handed as optional_args["apt_proxy_url"].

The driver reports facts instead (napalm-device-types 4.14):
get_package_proxy() says which proxy apt fetches through, None for none
or on a non-apt host; the updates are get_available_updates() as
before. get_device_warnings and the apt_proxy_url argument go.

BREAKING CHANGE: get_device_warnings and optional_args["apt_proxy_url"]
are removed. Requires napalm-device-types 4.14.

Closes #28
This commit is contained in:
Christian Manivong committed 2026-10-17 09:20:28 +02:00
1 parent 40f6ecd583
commit decd64b876
5 files changed
+39 -37

No files matched your search

+23
View File
@@ -211,3 +211,26 @@ class TestManagementPeer:
@pytest.mark.parametrize("answer", ["", "\n", "garbage", "not-an-ip 1 2 3"])
def test_nothing_usable_is_none(self, answer):
assert self._driver(answer).get_management_peer() is None
class TestFactsNotWarnings:
"""The driver reports facts; the application names warnings (#28, netOrk #1111)."""
def test_no_warnings_of_its_own(self):
assert "get_device_warnings" not in vars(LinuxDriver)
def test_the_package_proxy_apt_fetches_through(self, driver):
driver._send = lambda command, read_timeout=100: 'Acquire::http::Proxy "http://c:3142";'
assert driver.get_package_proxy() == "http://c:3142"
def test_no_proxy_set(self, driver):
driver._send = lambda command, read_timeout=100: ""
assert driver.get_package_proxy() is None
def test_not_an_apt_host(self, driver):
driver._pkg_manager = "dnf"
assert driver.get_package_proxy() is None
def test_the_applications_proxy_url_is_no_argument_any_more(self):
d = LinuxDriver("h", "admin", "p", optional_args={"apt_proxy_url": "http://c:3142"})
assert not hasattr(d, "_apt_proxy_url")
+1 -1
View File
@@ -123,7 +123,7 @@ def _driver(host: Host) -> LinuxDriver:
"h",
"admin",
"p",
optional_args={"sudo_password": _PW, "apt_proxy_url": "http://proxy:3142"},
optional_args={"sudo_password": _PW},
)
driver._device = MagicMock()
driver._device.send_command.side_effect = _shell