Merge "Display correct volume size in error message"

This commit is contained in:
Zuul 2017-11-22 08:53:56 +00:00 committed by Gerrit Code Review
commit 9d6e0ef332
2 changed files with 6 additions and 5 deletions

View File

@ -738,9 +738,9 @@ class ExtendForm(forms.SelfHandlingForm):
usages['totalGigabytesUsed']
if availableGB < (new_size - orig_size):
message = _('Volume cannot be extended to %(req)iGiB as '
'you only have %(avail)iGiB of your quota '
'available.')
params = {'req': new_size, 'avail': availableGB}
'the maximum size it can be extended to is '
'%(max_size)iGiB.')
params = {'req': new_size, 'max_size': (availableGB + orig_size)}
self._errors["new_size"] = self.error_class([message % params])
return cleaned_data

View File

@ -1732,8 +1732,9 @@ class VolumeViewTests(test.ResetImageAPIVersionMixin, test.TestCase):
args=[volume.id])
res = self.client.post(url, formData)
self.assertFormError(res, "form", "new_size",
"Volume cannot be extended to 1000GiB as you "
"only have 80GiB of your quota available.")
"Volume cannot be extended to 1000GiB as "
"the maximum size it can be extended to is "
"120GiB.")
mock_get.assert_called_once_with(test.IsHttpRequest(), volume.id)
self.assertEqual(2, mock_quotas.call_count)