1
0
mirror of https://github.com/checktheroads/hyperglass synced 2024-05-11 05:55:08 +00:00
Files
checktheroads-hyperglass/hyperglass/models/tests/test_util.py
2021-09-24 00:16:26 -07:00

31 lines
902 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)