Facts, ports, management address, LLDP (per-port and top-level shapes), MAC table and PoE from a UniFi device record, which a controller's stat/device and the device's own mca-dump share. Fixtures from aiounifi (MIT) and abates/napalm-unifi (Apache-2.0), anonymised with tools/sanitize.py. Refs NetOrk/netork#2787
53 lines
1.5 KiB
Python
53 lines
1.5 KiB
Python
"""Shared fixtures: recorded UniFi output, anonymised (see tests/fixtures/README.md)."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
import pathlib
|
|
from typing import Any
|
|
|
|
import pytest
|
|
|
|
FIXTURES = pathlib.Path(__file__).parent / "fixtures"
|
|
|
|
|
|
def load(name: str) -> Any:
|
|
"""A fixture file: JSON parsed, anything else as text."""
|
|
path = FIXTURES / name
|
|
text = path.read_text()
|
|
return json.loads(text) if path.suffix == ".json" else text
|
|
|
|
|
|
@pytest.fixture
|
|
def us16() -> dict[str, Any]:
|
|
"""A US-16-150W on 4.0.66, as the controller's ``stat/device`` reports it (old LLDP shape)."""
|
|
return load("controller/us16p150-4.0.66-stat-device.json") # type: ignore[no-any-return]
|
|
|
|
|
|
@pytest.fixture
|
|
def us8() -> dict[str, Any]:
|
|
return load("controller/us8-4.0.66-stat-device.json") # type: ignore[no-any-return]
|
|
|
|
|
|
@pytest.fixture
|
|
def usmini() -> dict[str, Any]:
|
|
"""A USW Flex Mini on 1.8.4: the top-level LLDP shape."""
|
|
return load("controller/usmini-1.8.4-stat-device.json") # type: ignore[no-any-return]
|
|
|
|
|
|
@pytest.fixture
|
|
def uap() -> dict[str, Any]:
|
|
"""A UAP-AC-Pro (U7PG2) on 4.0.69, as the controller reports it."""
|
|
return load("controller/u7pg2-4.0.69-stat-device.json") # type: ignore[no-any-return]
|
|
|
|
|
|
@pytest.fixture
|
|
def us24_dump() -> dict[str, Any]:
|
|
"""A US-24 (Gen1) on 7.1.26: ``mca-dump`` over SSH, no controller in between."""
|
|
return load("ssh/us24-7.1.26-mca-dump.json") # type: ignore[no-any-return]
|
|
|
|
|
|
@pytest.fixture
|
|
def us24_cfg() -> str:
|
|
return load("ssh/us24-7.1.26-running.cfg") # type: ignore[no-any-return]
|