1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-12-02 17:06:09 +00:00
webvirtcloud/operations/tests/test_public_error.py
catborise 2db25314ea fix(instances): USB device changes as PCI ones; device refusals name no VM to owners
- A USB device added to or removed from a VM with a saved state applied
  only at the next cold boot: refused now, as for PCI devices, and the
  form says so.
- A USB hot plug or removal that failed half way said only libvirt's
  error: it now says where the device is, as for PCI devices
  (_hostdev_outcome, shared).
- A host device refusal (check_hostdevs) names the other VMs that have
  the device; users who do not see the hosts, such as an owner whose
  snapshot revert is refused, now read that a device is not free and that
  an administrator can see why.
- The host's USB devices named among a PCI device's host resources were
  English in every language.
2026-11-11 22:58:40 +03:00

23 lines
1.2 KiB
Python

"""A job's checks in the worker refuse with Django's exceptions, which carry
no text: the job's error says why instead of being empty."""
from django.core.exceptions import PermissionDenied
from django.http import Http404
from django.test import SimpleTestCase
from operations.utils import public_error_text
class PublicErrorTests(SimpleTestCase):
def test_a_refusal_says_why(self):
self.assertEqual(public_error_text(PermissionDenied()), "You may no longer do this.")
self.assertEqual(public_error_text(Http404("No Instance matches the given query.")),
"The virtual machine is no longer in the panel.")
def test_a_host_device_refusal_names_no_other_vm(self):
from vrtManager.nodedevs import HostDevicesRefused
from vrtManager.util import message
refused = HostDevicesRefused("%(problems)s", problems=[message("%(device)s is given to %(vms)s",
device="PCI device 0000:00:0a.0", vms="private-db-1")])
self.assertNotIn("private-db-1", public_error_text(refused))
self.assertIn("Host devices tab", public_error_text(refused))