mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-08 19:26:48 +00:00
sortable.js 0.8.0 (abandoned since 2014) sorted only a table's first
body: in the grouped VM list the first host's row moved among its VMs
and the other hosts never sorted, and memory sorted as text ("1024 MB"
before "512 MB"). tablesort 5.7.1 sorts each table body on its own and
keeps a row marked data-sort-method="none" in place, so hosts stay in
name order with their row on top and their VMs sort below it. Memory,
vCPUs and volume sizes sort by their numbers (data-sort). Headers are
reachable by keyboard and carry aria-sort.
base.html loads tablesort for every table marked data-sortable; the
per-page sortable includes and sortable-theme-bootstrap.css go, so these
tables take the theme's table style like the others. The grouped list's
row numbers go (meaningless once sorted). The VM owners and VM logs
tables were marked sortable but never loaded the script; they stay
unsorted.
44 lines
1.8 KiB
Python
44 lines
1.8 KiB
Python
"""Tests for the instances list after out-of-band libvirt changes."""
|
|
|
|
from unittest.mock import PropertyMock, patch
|
|
|
|
from computes.models import Compute
|
|
from django.contrib.auth import get_user_model
|
|
from django.test import TestCase
|
|
from django.urls import reverse
|
|
from instances.models import Instance
|
|
|
|
|
|
class InstancesIndexTests(TestCase):
|
|
def test_removed_domain_is_not_rendered_from_prefetch_cache(self):
|
|
user = get_user_model().objects.create_superuser(
|
|
username="instances-index-admin", password="password", email="index@example.com"
|
|
)
|
|
self.client.force_login(user)
|
|
compute = Compute.objects.create(
|
|
name="index-compute", hostname="localhost", type=4,
|
|
login="", password="",
|
|
)
|
|
instance = Instance.objects.create(
|
|
compute=compute, name="test4", uuid="cb2a2697-0945-408a-ac6b-c3e07a280851"
|
|
)
|
|
self.assertEqual(Compute.objects.count(), 1)
|
|
|
|
def synchronize(_compute):
|
|
Instance.objects.filter(pk=instance.pk).delete()
|
|
self.assertFalse(Instance.objects.filter(pk=instance.pk).exists())
|
|
|
|
with patch("instances.views.utils.refr", side_effect=synchronize), patch.object(
|
|
Compute, "status", new_callable=PropertyMock, return_value=True
|
|
), patch.object(
|
|
Compute, "cpu_count", new_callable=PropertyMock, return_value=1
|
|
), patch.object(
|
|
Compute, "ram_size", new_callable=PropertyMock, return_value=1024
|
|
), patch.object(
|
|
Compute, "ram_usage", new_callable=PropertyMock, return_value=0
|
|
):
|
|
response = self.client.get(reverse("instances:index"))
|
|
|
|
self.assertEqual(response.status_code, 200)
|
|
self.assertNotContains(response, "test4")
|
|
self.assertEqual(list(response.context["computes"][0].instance_set.all()), [])
|