1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-11-08 11:16:47 +00:00
webvirtcloud/computes/tests/test_host_nav.py
catborise 0671dc67a0 style(computes): the host's sections on one line in every theme
- The host navigation takes one font size and spaces its dividers alike on
  both sides in every theme: Zephyr doubled the space after each divider,
  and with the Devices section its eight sections took two lines.
- Its labels are shorter: Storage, Filters.
- Measured in the 27 themes at 992, 1200 and 1440 px: one line in each,
  with at least 73 px to spare (Lux had 20 px before, Zephyr was 13 px
  short).
2026-10-29 15:50:31 +03:00

25 lines
1 KiB
Python

"""The host pages' shared section links."""
from django.template.loader import render_to_string
from django.test import TestCase
from lxml import html
from computes.models import Compute
class HostNavTestCase(TestCase):
def setUp(self):
self.compute = Compute.objects.create(name="c", hostname="192.0.2.1", login="u", password="p", type=1)
def items(self, **context):
nav = html.fromstring(render_to_string("computes/host_nav.html", {"compute": self.compute, **context}))
return {item.text_content().strip(): (item.tag, item.get("aria-current")) for item in nav.xpath("//li/*")}
def test_the_section_s_own_page_is_the_current_page(self):
items = self.items(section="storages")
self.assertEqual(len(items), 8)
self.assertEqual(items["Storage"], ("span", "page"))
self.assertEqual(items["Overview"], ("a", None))
def test_an_item_of_a_section_links_the_section_as_where_it_is(self):
self.assertEqual(self.items(section="networks", detail=True)["Networks"], ("a", "true"))