first commit
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
from pathlib import Path
|
||||
import unittest
|
||||
|
||||
from librenet_scanner.models import Host
|
||||
from librenet_scanner.visual_identity import device_icon_key_for_host, os_icon_key_for_host
|
||||
|
||||
|
||||
class V0414IconTests(unittest.TestCase):
|
||||
def test_equipment_categories_are_distinct(self):
|
||||
cases = [
|
||||
(Host(ip='192.0.2.1', device_type='Poste'), 'workstation'),
|
||||
(Host(ip='192.0.2.2', device_type='Serveur Linux'), 'server'),
|
||||
(Host(ip='192.0.2.3', device_type='NAS Synology'), 'nas'),
|
||||
(Host(ip='192.0.2.4', device_type='Switch'), 'switch'),
|
||||
(Host(ip='192.0.2.5', device_type="Point d'accès Wi-Fi"), 'access-point'),
|
||||
(Host(ip='192.0.2.6', device_type='Imprimante'), 'printer'),
|
||||
(Host(ip='192.0.2.7', device_type='Pare-feu / routeur'), 'firewall'),
|
||||
]
|
||||
for host, expected in cases:
|
||||
with self.subTest(expected=expected):
|
||||
self.assertEqual(device_icon_key_for_host(host), expected)
|
||||
|
||||
def test_os_families(self):
|
||||
self.assertEqual(os_icon_key_for_host(Host(ip='1.1.1.1', os_name='Linux 6.1')), 'linux')
|
||||
self.assertEqual(os_icon_key_for_host(Host(ip='1.1.1.2', os_name='FreeBSD 14.1')), 'bsd')
|
||||
self.assertEqual(os_icon_key_for_host(Host(ip='1.1.1.3', os_name='Windows 11')), 'windows')
|
||||
|
||||
def test_fontawesome_assets_replaced_homemade_icons(self):
|
||||
root = Path(__file__).resolve().parents[1]
|
||||
icons = root / 'assets' / 'icons'
|
||||
expected = {
|
||||
'os-linux.svg', 'os-bsd.svg', 'os-windows.svg',
|
||||
'equipment-workstation.svg', 'equipment-server.svg',
|
||||
'equipment-firewall.svg', 'equipment-switch.svg',
|
||||
'equipment-access-point.svg', 'equipment-printer.svg',
|
||||
}
|
||||
self.assertTrue(expected.issubset({p.name for p in icons.glob('*.svg')}))
|
||||
# Homemade 0.4.13 BSD path included a tail/staff; FA FreeBSD glyph is larger and contains many curves.
|
||||
bsd=(icons/'os-bsd.svg').read_text()
|
||||
self.assertIn('Font Awesome', (root/'THIRD_PARTY_ASSETS.md').read_text())
|
||||
self.assertGreater(len(bsd), 500)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user