mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-09 11:46:49 +00:00
feat(operations): a job's error and warning show in the reader's language
A job stored its error and its result's warning as English text, much of it built with the values in it (volume paths, a disk, libvirt's error), so no catalog could translate it, and the job pages and panel showed English whatever the language. A job now stores them as messages: our English text, marked for translation, and its values; libvirt's own text is a message without values and is shown as it is. The jobs API and pages put them in the reader's language. OperationError keeps its text and values apart for the same reason, so a refusal raised while a job is submitted is shown translated too. Messages one after another still read as sentences. Errors stored before are kept as one message each, shown as they were.
This commit is contained in:
parent
0eab09e19d
commit
1e66367bb4
29 changed files with 927 additions and 333 deletions
|
|
@ -12,6 +12,7 @@ from instances.models import Instance
|
|||
from operations import claims, jobs
|
||||
from operations.models import Claim, Operation
|
||||
from operations.tests import fakes
|
||||
from operations.utils import say
|
||||
|
||||
|
||||
class OperationsApiTestCase(TransactionTestCase):
|
||||
|
|
@ -35,6 +36,17 @@ class OperationsApiTestCase(TransactionTestCase):
|
|||
Operation.objects.filter(pk=self.op.pk).update(time_limit=60, started_at=timezone.now() - timedelta(seconds=61))
|
||||
self.assertEqual(self.client.get(url).json()["phase"], "Merging the snapshot (over its time limit)")
|
||||
|
||||
def test_the_error_and_warning_come_in_the_users_language_with_their_values(self):
|
||||
# ours with its values; libvirt's text as it is
|
||||
Operation.objects.filter(pk=self.op.pk).update(
|
||||
state=Operation.FAILED,
|
||||
error=say("The pool has no volume named %(name)s", name="disk.qcow2") + say("unable to open: busy"),
|
||||
result={"warning": say("The copy was not made")})
|
||||
self.client.force_login(self.owner)
|
||||
job = self.client.get(f"/api/v1/operations/{self.op.pk}/", HTTP_ACCEPT_LANGUAGE="tr").json()
|
||||
self.assertEqual(job["error"], "Havuzda disk.qcow2 adında birim yok. unable to open: busy")
|
||||
self.assertEqual(job["result"]["warning"], "Kopya oluşturulmadı")
|
||||
|
||||
def test_users_list_only_their_own_jobs(self):
|
||||
self.client.force_login(self.other)
|
||||
self.assertEqual(self.client.get("/api/v1/operations/").json()["count"], 0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue