Files
oxipy/tests/test_models.py
IluaAir 8edd1a296c Add H3C device support with configuration and expected output files
- Introduced support for H3C devices by adding a new configuration file `config.conf` containing interface and VLAN settings.
- Created an expected output JSON file `config.expected.json` to validate the parsing of H3C configurations.
- Updated the test model cases to include H3C for comprehensive testing of device parsing functionality.
2026-06-11 16:16:14 +03:00

40 lines
1.4 KiB
Python

import json
import pytest
from conftest import FIXTURES, load
from oxi.interfaces import device_registry
MODEL_CASES = [
("mikrotik", "config.conf", "config.expected.json"),
("keenetic", "config.conf", "config.expected.json"),
("qtech", "config_1.conf", "config_1.expected.json"),
("qtech", "config_2.conf", "config_2.expected.json"),
("huawei", "config.conf", "config.expected.json"),
("eltex", "config.conf", "config.expected.json"),
("h3c", "config.conf", "config.expected.json"),
("quasar", "config_1.conf", "config_1.expected.json"),
("quasar", "config_2.conf", "config_2.expected.json"),
]
@pytest.mark.parametrize("model_key, fixture, expected_file", MODEL_CASES)
def test_parse_matches_golden(model_key, fixture, expected_file):
cls = device_registry[model_key]
raw = load(model_key, fixture)
parsed = cls(raw).parse().model_dump(by_alias=True, mode="json")
expected = json.loads((FIXTURES / model_key / expected_file).read_text("utf-8"))
assert parsed == expected
@pytest.mark.parametrize("model_key, fixture, _expected", MODEL_CASES)
def test_parse_has_required_sections(model_key, fixture, _expected):
cls = device_registry[model_key]
device = cls(load(model_key, fixture)).parse()
assert device.system is not None
assert isinstance(device.interfaces, list)
assert isinstance(device.vlans, list)