mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-01 08:26:03 +00:00
fix(instances): the Secure Boot machine type warning is in the user's language
A new VM with UEFI Secure Boot on a machine type other than q35 is made on q35, and the create page says so. That warning was an English-only string; it is now a translated message, with Turkish and Chinese texts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Kk4h2TcUiaWmU5MUszYSea
This commit is contained in:
parent
9fa898a856
commit
a4bfe77949
6 changed files with 34 additions and 17 deletions
|
|
@ -4,7 +4,9 @@ from types import SimpleNamespace
|
|||
from unittest.mock import MagicMock, patch
|
||||
|
||||
from computes.models import Compute
|
||||
from django.conf import settings
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.contrib.messages import get_messages
|
||||
from django.test import SimpleTestCase, TestCase
|
||||
from django.urls import reverse
|
||||
from instances.api.serializers import CreateInstanceSerializer
|
||||
|
|
@ -73,6 +75,14 @@ class CreateInstanceViewTests(TestCase):
|
|||
self.assertEqual((kwargs["firmware"], kwargs["machine"], kwargs["tpm_model"]),
|
||||
("UEFI Secure Boot", "q35", "tpm-crb"))
|
||||
|
||||
@patch("instances.views.wvmCreate", new=wvm_create)
|
||||
@patch("instances.views.NewVMForm")
|
||||
def test_secure_boot_on_another_machine_type_says_so_in_the_users_language(self, form_class):
|
||||
self.client.cookies[settings.LANGUAGE_COOKIE_NAME] = "tr"
|
||||
response, _ = self.create(form_class, machine="pc", firmware="UEFI Secure Boot")
|
||||
self.assertEqual([str(m) for m in get_messages(response.wsgi_request)],
|
||||
["Makine türü pc değil q35: UEFI Secure Boot bunu gerektiriyor"])
|
||||
|
||||
@patch("instances.views.wvmCreate", new=wvm_create)
|
||||
@patch("instances.views.NewVMForm")
|
||||
def test_a_firmware_or_a_tpm_the_host_does_not_offer_is_refused(self, form_class):
|
||||
|
|
@ -103,7 +113,7 @@ class CreateInstanceViewTests(TestCase):
|
|||
conn.create_volume.assert_not_called()
|
||||
conn.create_instance.assert_not_called()
|
||||
|
||||
def create(self, form_class, host=None, **data):
|
||||
def create(self, form_class, host=None, machine="q35", **data):
|
||||
"""POST the create form with data over the form's defaults; host: what
|
||||
the mocked host answers, over its defaults."""
|
||||
user = get_user_model().objects.filter(username="create-test-admin").first() or (
|
||||
|
|
@ -150,7 +160,7 @@ class CreateInstanceViewTests(TestCase):
|
|||
}
|
||||
|
||||
response = self.client.post(
|
||||
reverse("instances:create_instance", args=[compute.id, "x86_64", "q35"]),
|
||||
reverse("instances:create_instance", args=[compute.id, "x86_64", machine]),
|
||||
{"create": "1", "device0": "disk", "bus0": "virtio", "submission_key": "key-create01"},
|
||||
)
|
||||
return response, conn
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue