"""The SNMP list says each device's state with the shared badge and shows its
readings as stat tiles (#5126)."""
from tests._templates import render_plugin_template
from tests.test_style_tokens import hex_colours
async def test_devices_wear_a_status_badge_and_readings_are_tiles(app):
devices = [
{"name": "ups", "host": "10.0.0.9", "oids": [{"oid": "1.3.6", "label": "battery_charge_pct"},
{"oid": "1.3.7", "label": "in_octets"}],
"readings": {"battery_charge_pct": 97.0, "in_octets": 2_500_000.0}},
{"name": "printer", "host": "10.0.0.10", "oids": [], "readings": {}},
]
async with app.test_request_context("/plugins/snmp/"):
page = await render_plugin_template(app, "snmp", "snmp/index.html", devices=devices, poll_interval=60)
assert 'Reachable' in page
assert 'No data yet' in page
assert '97' in page and '2.50M' in page
assert 'href="/plugins/snmp/device/ups"' in page
main = page[page.index("