mirror of
https://github.com/thatmattlove/hyperglass.git
synced 2026-01-27 20:39:19 +00:00
Due to changes in tooling from the originals used file formats have changed. pnpm 10.10.0 rye 0.44.0 ruff 0.11.8 CI is now testing on a matrix of pnpm, node, and python versions. This will hopefully cover edgecases where users are running various version. Still needs update to use python version in matrix with `rye`. Installs OS deps in workflow Adds 'packages' key in workspace form pnpm 9 Makes testing for BaseExternal configurable Adds redis and httpbin as service containers ruff lint changed dictionary comprehensions adds environment variables for httpbin Fixes runner to docker communications
30 lines
904 B
Python
30 lines
904 B
Python
"""Test model utilities."""
|
|
|
|
# Third Party
|
|
import pytest
|
|
|
|
# Local
|
|
from ..util import check_legacy_fields
|
|
|
|
|
|
@pytest.mark.dependency()
|
|
def test_check_legacy_fields():
|
|
test1 = {"name": "Device A", "nos": "juniper"}
|
|
test1_expected = {"name": "Device A", "platform": "juniper"}
|
|
test2 = {"name": "Device B", "platform": "juniper"}
|
|
test3 = {"name": "Device C"}
|
|
test4 = {"name": "Device D", "network": "this is wrong"}
|
|
|
|
assert set(check_legacy_fields(model="Device", data=test1).keys()) == set(
|
|
test1_expected.keys()
|
|
), "legacy field not replaced"
|
|
|
|
assert set(check_legacy_fields(model="Device", data=test2).keys()) == set(test2.keys()), (
|
|
"new field not left unmodified"
|
|
)
|
|
|
|
with pytest.raises(ValueError):
|
|
check_legacy_fields(model="Device", data=test3)
|
|
|
|
with pytest.raises(ValueError):
|
|
check_legacy_fields(model="Device", data=test4)
|