first commit
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
from librenet_scanner.models import Host
|
||||
from librenet_scanner.visual_identity import (
|
||||
EQUIPMENT_ICON_FILES,
|
||||
OS_ICON_FILES,
|
||||
device_icon_key_for_host,
|
||||
os_icon_key_for_host,
|
||||
)
|
||||
|
||||
|
||||
class EquipmentIdentityTests(unittest.TestCase):
|
||||
def test_local_host_is_workstation(self):
|
||||
self.assertEqual(device_icon_key_for_host(Host("192.0.2.1", is_local=True, device_type="Ce poste")), "workstation")
|
||||
|
||||
def test_linux_server_is_server_not_workstation(self):
|
||||
host = Host("192.0.2.2", device_type="Serveur Linux", os_name="Debian GNU/Linux 13")
|
||||
self.assertEqual(device_icon_key_for_host(host), "server")
|
||||
self.assertEqual(os_icon_key_for_host(host), "linux")
|
||||
|
||||
def test_openwrt_is_generic_network_device(self):
|
||||
host = Host("192.0.2.3", device_type="Serveur Linux", os_name="OpenWrt 24.10")
|
||||
self.assertEqual(device_icon_key_for_host(host), "network-device")
|
||||
self.assertEqual(os_icon_key_for_host(host), "linux")
|
||||
|
||||
def test_opnsense_is_firewall_and_bsd(self):
|
||||
host = Host("192.0.2.4", device_type="Serveur / appliance", os_name="OPNsense 25.1 (FreeBSD 14)")
|
||||
self.assertEqual(device_icon_key_for_host(host), "firewall")
|
||||
self.assertEqual(os_icon_key_for_host(host), "bsd")
|
||||
|
||||
def test_nas_switch_ap_printer_have_distinct_classes(self):
|
||||
cases = {
|
||||
"NAS Synology": "nas",
|
||||
"Switch": "switch",
|
||||
"Point d'accès Wi-Fi": "access-point",
|
||||
"Imprimante": "printer",
|
||||
}
|
||||
for dtype, expected in cases.items():
|
||||
with self.subTest(dtype=dtype):
|
||||
self.assertEqual(device_icon_key_for_host(Host("192.0.2.10", device_type=dtype)), expected)
|
||||
|
||||
|
||||
class IconAssetTests(unittest.TestCase):
|
||||
def test_all_equipment_assets_exist(self):
|
||||
root = Path(__file__).resolve().parents[1] / "assets" / "icons"
|
||||
for filename in EQUIPMENT_ICON_FILES.values():
|
||||
with self.subTest(filename=filename):
|
||||
self.assertTrue((root / filename).is_file(), filename)
|
||||
|
||||
def test_all_os_assets_exist(self):
|
||||
root = Path(__file__).resolve().parents[1] / "assets" / "icons"
|
||||
for filename in OS_ICON_FILES.values():
|
||||
with self.subTest(filename=filename):
|
||||
self.assertTrue((root / filename).is_file(), filename)
|
||||
|
||||
def test_equipment_assets_are_not_os_assets(self):
|
||||
self.assertTrue(set(EQUIPMENT_ICON_FILES.values()).isdisjoint(OS_ICON_FILES.values()))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user