1
0
Fork 1
mirror of https://github.com/thatmattlove/hyperglass.git synced 2026-01-17 08:48:05 +00:00
thatmattlove-hyperglass/hyperglass/state/tests/test_hooks.py

30 lines
816 B
Python

"""Test state hooks."""
# Project
from hyperglass.models.ui import UIParameters
from hyperglass.models.config.params import Params
from hyperglass.models.config.devices import Devices
# Local
from ..hooks import use_state
from ..store import HyperglassState
STATE_ATTRS = (
("params", Params),
("devices", Devices),
("ui_params", UIParameters),
(None, HyperglassState),
)
def test_use_state_caching():
first = None
for attr, model in STATE_ATTRS:
for i in range(0, 5):
instance = use_state(attr)
if i == 0:
first = instance
assert isinstance(
instance, model
), f"{instance!r} is not an instance of '{model.__name__}'"
assert instance == first, f"{instance!r} is not equal to {first!r}"