test(facts): check get_facts against the gateway's recorded answers (#24)
driver / standard (pull_request) Successful in 18s
driver / lint (pull_request) Successful in 16s
driver / types (pull_request) Successful in 1m5s
driver / test (3.13) (pull_request) Successful in 1m10s
driver / test (3.12) (pull_request) Successful in 1m12s
driver / lowest (pull_request) Successful in 29s
driver / build (pull_request) Successful in 31s
driver / security (pull_request) Successful in 1m5s
CI / driver (pull_request) Successful in 2m35s
driver / publish (pull_request) Skipped
driver / standard (pull_request) Successful in 18s
driver / lint (pull_request) Successful in 16s
driver / types (pull_request) Successful in 1m5s
driver / test (3.13) (pull_request) Successful in 1m10s
driver / test (3.12) (pull_request) Successful in 1m12s
driver / lowest (pull_request) Successful in 29s
driver / build (pull_request) Successful in 31s
driver / security (pull_request) Successful in 1m5s
CI / driver (pull_request) Successful in 2m35s
driver / publish (pull_request) Skipped
get_facts read SerialNumber, HostName, SystemUpTime and MacAddress from getBasicInformation, which a VMG4005-B50A (V5.17(ABQA.3.1)C0) answers with model, firmware and language settings only. The code was fixed by #26 (host name and domain from the System page) and #28 (serial number and uptime from cardpage_status); the tests still fed it an invented getBasicInformation (MOCK_BASIC_INFO) that carried those fields, with an invented serial number and firmware. MOCK_BASIC_INFO is now the recorded answer, and a new test reads the facts from the recorded, sealed status page and the System page: it fails against the driver before #26 with the symptoms of this issue (serial "", uptime 0, host name the connection address). The README names the sources get_facts reads. Closes #24
This commit is contained in:
1 parent
3213dfaaaa
commit
b6668eddbd
4 files changed
+42
-23
No files matched your search
@@ -26,6 +26,7 @@ import pytest
|
||||
import requests
|
||||
|
||||
from napalm_zyxel import ZyxelVMGDriver
|
||||
from tests import gateway
|
||||
|
||||
BASIC_INFO: dict[str, Any] = {
|
||||
"result": "ZCFG_SUCCESS",
|
||||
@@ -174,3 +175,29 @@ def test_get_facts_reads_the_status_page_once():
|
||||
def test_get_facts_raises_when_the_status_page_cannot_be_read():
|
||||
with pytest.raises(RuntimeError, match="cardpage_status"):
|
||||
_driver(status=_response(500)).get_facts()
|
||||
|
||||
|
||||
# --- the recorded answers (#24) ---------------------------------------------------------
|
||||
|
||||
|
||||
def test_the_facts_of_the_recorded_gateway():
|
||||
"""``getBasicInformation`` gives model and firmware only; nothing else is read from
|
||||
it. The status page is the full recorded one, sealed (``tests/gateway.py``)."""
|
||||
drv = gateway.driver(
|
||||
{gateway.dal("cardpage_status"): gateway.fixture("cardpage_status"), SYSTEM_PATH: SYSTEM}
|
||||
)
|
||||
assert drv._device_info == gateway.fixture("getBasicInformation")
|
||||
assert drv.get_facts() == {
|
||||
"vendor": "Zyxel",
|
||||
"model": "VMG4005-B50A",
|
||||
"serial_number": "S000Y00000001",
|
||||
"os_version": "V5.17(ABQA.3.1)C0",
|
||||
"hostname": "VMG4005-B50A",
|
||||
"fqdn": "VMG4005-B50A.home",
|
||||
"uptime": 13554213,
|
||||
"interface_list": ["br0", "atm0.1", "ptm0.2", "eth1"],
|
||||
}
|
||||
|
||||
|
||||
def test_basic_information_is_the_recorded_answer():
|
||||
assert BASIC_INFO == gateway.fixture("getBasicInformation")
|
||||
Reference in new issue
Block a user