Support Django 3.0 and 3.1 support (3)
The result of the encoded (i.e., escaped) text in HTML changed
between Django pre-3.0 and 3.0+. For example, decimal and hex encoding
are semantically same but they are different in literal texts.
While I don't know what triggers this change, I think it makes sense
to compare these texts after decoding as HTML.
Considering this, html=True is passed to self.assertContains().
When passing html=True, a text in an HTML element is not compared
partially and a full text as a value of the HTML element is compared,
so we need to pass the full text of an HTML element value now.
I believe the above change is caused by the change that django.test.html.Parser
is initialized with convert_charrefs=False previously. On the other hand,
it is not specified now in Django 3.0+ [1]. This leads to the situation that
escapes on unicode characters are handled differently.
[1] 48235ba807
Change-Id: I0f26436eb384a95f8446d8fd447c9577d50a5c21
This commit is contained in:
parent
be12ce1e96
commit
a0dd4d738c
@ -3454,8 +3454,10 @@ class InstanceLaunchInstanceTests(InstanceTestBase,
|
||||
image.min_disk = flavor.disk + 1
|
||||
keypair = self.keypairs.first()
|
||||
res = self._launch_form_instance(image, flavor, keypair)
|
||||
msg = "The flavor '%s' is too small" % flavor.name
|
||||
self.assertContains(res, msg)
|
||||
msg = (f"The flavor '{flavor.name}' is too small for requested "
|
||||
f"image. Minimum requirements: {image.min_ram} MB of RAM and "
|
||||
f"{image.min_disk} GB of Root Disk.")
|
||||
self.assertContains(res, msg, html=True)
|
||||
|
||||
def test_launch_form_instance_requirement_error_ram(self):
|
||||
flavor = self.flavors.first()
|
||||
@ -3464,8 +3466,10 @@ class InstanceLaunchInstanceTests(InstanceTestBase,
|
||||
image.min_disk = flavor.disk
|
||||
keypair = self.keypairs.first()
|
||||
res = self._launch_form_instance(image, flavor, keypair)
|
||||
msg = "The flavor '%s' is too small" % flavor.name
|
||||
self.assertContains(res, msg)
|
||||
msg = (f"The flavor '{flavor.name}' is too small for requested "
|
||||
f"image. Minimum requirements: {image.min_ram} MB of RAM and "
|
||||
f"{image.min_disk} GB of Root Disk.")
|
||||
self.assertContains(res, msg, html=True)
|
||||
|
||||
def test_launch_form_instance_zero_value_flavor_with_min_req(self):
|
||||
flavor = self.flavors.first()
|
||||
@ -3474,8 +3478,10 @@ class InstanceLaunchInstanceTests(InstanceTestBase,
|
||||
image.min_disk = flavor.disk + 1
|
||||
keypair = self.keypairs.first()
|
||||
res = self._launch_form_instance(image, flavor, keypair)
|
||||
msg = "The flavor '%s' is too small" % flavor.name
|
||||
self.assertNotContains(res, msg)
|
||||
msg = (f"The flavor &39;{flavor.name}&39; is too small for requested "
|
||||
f"image. Minimum requirements: {image.min_ram} MB of RAM and "
|
||||
f"{image.min_disk} GB of Root Disk.")
|
||||
self.assertNotContains(res, msg, html=True)
|
||||
|
||||
@helpers.create_mocks({api.glance: ('image_list_detailed',),
|
||||
api.neutron: ('network_list',
|
||||
@ -3707,7 +3713,7 @@ class InstanceLaunchInstanceTests(InstanceTestBase,
|
||||
url = reverse('horizon:project:instances:launch')
|
||||
|
||||
res = self.client.post(url, form_data)
|
||||
self.assertContains(res, msg)
|
||||
self.assertContains(res, msg, html=True)
|
||||
|
||||
self.mock_keypair_list.assert_called_once_with(helpers.IsHttpRequest())
|
||||
self.mock_security_group_list.assert_called_once_with(
|
||||
@ -3751,8 +3757,9 @@ class InstanceLaunchInstanceTests(InstanceTestBase,
|
||||
def test_launch_form_instance_volume_size_error(self):
|
||||
image = self.versioned_images.get(name='protected_images')
|
||||
volume_size = image.min_disk // 2
|
||||
msg = ("The Volume size is too small for the '%s' image" %
|
||||
image.name)
|
||||
msg = ("The Volume size is too small for the '%s' image "
|
||||
"and has to be greater than or equal to '%s' GB." %
|
||||
(image.name, image.min_disk))
|
||||
self._test_launch_form_instance_volume_size(image, volume_size, msg)
|
||||
|
||||
def test_launch_form_instance_non_int_volume_size(self):
|
||||
@ -3762,7 +3769,8 @@ class InstanceLaunchInstanceTests(InstanceTestBase,
|
||||
|
||||
def test_launch_form_instance_volume_exceed_quota(self):
|
||||
image = self.versioned_images.get(name='protected_images')
|
||||
msg = "Requested volume exceeds quota: Available: 0, Requested: 1"
|
||||
msg = ("The requested instance cannot be launched. "
|
||||
"Requested volume exceeds quota: Available: 0, Requested: 1.")
|
||||
self._test_launch_form_instance_volume_size(image, image.min_disk,
|
||||
msg, 0)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user