fix!: reboot_host instead of reboot; drop run_device_action (0.2.0)
CI / test (3.10) (push) Successful in 3m5s
CI / test (3.11) (push) Successful in 23s
CI / test (3.12) (push) Successful in 24s
CI / test (3.10) (pull_request) Successful in 3m3s
CI / test (3.11) (pull_request) Successful in 23s
CI / test (3.12) (pull_request) Successful in 24s
CI / test (3.10) (push) Successful in 3m5s
CI / test (3.11) (push) Successful in 23s
CI / test (3.12) (push) Successful in 24s
CI / test (3.10) (pull_request) Successful in 3m3s
CI / test (3.11) (pull_request) Successful in 23s
CI / test (3.12) (pull_request) Successful in 24s
The gateway had reboot(), but the contract (HostRebootMixin) and the application look for reboot_host(), so the gateway could not be restarted from it. reboot_host() returns None and raises when the gateway refuses, as the contract says. run_device_action dispatched reboot, restart_wifi[:band] and get_diagnostics by string, with a result shape other than its contract's. restart_wifi(band) and get_diagnostics() are methods now; napalm-device-types deprecates run_device_action. BREAKING CHANGE: reboot() and run_device_action are removed. Closes #5. Part of #6.
This commit is contained in:
1 parent
efdf62c8be
commit
210f00f5e7
3 files changed
+28
-48
No files matched your search
+14
-9
@@ -1,6 +1,7 @@
|
||||
import json
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
import pytest
|
||||
import requests
|
||||
|
||||
from napalm.base.exceptions import ConnectionException
|
||||
@@ -285,16 +286,20 @@ class TestZyxelVMGDriver:
|
||||
self._setup_mocked_http()
|
||||
assert self.driver.get_arp_table() == []
|
||||
|
||||
def test_reboot(self):
|
||||
self._setup_mocked_http()
|
||||
result = self.driver.run_device_action("reboot")
|
||||
assert result["action"] == "reboot"
|
||||
def test_reboot_host_is_the_contract_the_application_calls(self):
|
||||
"""It was reboot(), which nothing looks for: the gateway could not be
|
||||
restarted from the application (#5)."""
|
||||
self.driver._dal_query = lambda name, data: {"result": "ZCFG_SUCCESS"}
|
||||
assert self.driver.reboot_host() is None
|
||||
|
||||
def test_run_device_action_unknown(self):
|
||||
self._setup_mocked_http()
|
||||
result = self.driver.run_device_action("foobar")
|
||||
assert result["success"] is False
|
||||
assert "Unknown" in result["message"]
|
||||
def test_a_refused_reboot_raises(self):
|
||||
self.driver._dal_query = lambda name, data: {"result": "ZCFG_FAIL"}
|
||||
with pytest.raises(RuntimeError):
|
||||
self.driver.reboot_host()
|
||||
|
||||
def test_run_device_action_and_reboot_are_gone(self):
|
||||
assert not hasattr(type(self.driver), "run_device_action")
|
||||
assert not hasattr(type(self.driver), "reboot")
|
||||
|
||||
def test_load_replace_candidate_raises(self):
|
||||
self._setup_mocked_http()
|
||||
|
||||
Reference in new issue
Block a user