Merge "django22: django.test.client.encode_multipart no longer accepts None"

This commit is contained in:
Zuul 2019-09-11 01:43:07 +00:00 committed by Gerrit Code Review
commit 9f4055450f
5 changed files with 49 additions and 46 deletions

View File

@ -431,9 +431,9 @@ class CreateFlavorWorkflowTests(BaseFlavorWorkflowTests):
workflow_data = self._get_workflow_data(flavor)
# Swap field empty
workflow_data['swap'] = None
del workflow_data['swap_mb']
# Ephemeral field empty
workflow_data['eph'] = None
del workflow_data['eph_gb']
url = reverse(constants.FLAVORS_CREATE_URL)
res = self.client.post(url, workflow_data)

View File

@ -131,9 +131,9 @@ class RBACPolicyTests(test.BaseAdminViewTests):
self.mock_network_list.return_value = self.networks.list()
self.mock_is_extension_supported.return_value = False
# note that 'network_id' is not included
form_data = {'target_tenant': rbac_policy.target_tenant,
'action_object_type': 'external_network',
'network_id': None}
'action_object_type': 'external_network'}
url = reverse('horizon:admin:rbac_policies:create')
res = self.client.post(url, form_data)
@ -161,9 +161,9 @@ class RBACPolicyTests(test.BaseAdminViewTests):
self.mock_policy_list.return_value = self.qos_policies.list()
self.mock_is_extension_supported.return_value = True
# note that 'qos_policy_id' is not included
form_data = {'target_tenant': rbac_policy.target_tenant,
'action_object_type': 'shared_qos_policy',
'qos_policy_id': None}
'action_object_type': 'shared_qos_policy'}
url = reverse('horizon:admin:rbac_policies:create')
res = self.client.post(url, form_data)

View File

@ -127,6 +127,12 @@ class UsersViewTests(test.BaseAdminViewTests):
'enabled': True,
'confirm_password': user.password,
'phone_num': phone_number}
# django.test.client doesn't like None fields in forms
for key in list(formData):
if formData[key] is None:
del formData[key]
res = self.client.post(USER_CREATE_URL, formData)
self.assertNoFormErrors(res)
@ -195,6 +201,12 @@ class UsersViewTests(test.BaseAdminViewTests):
'project': self.tenant.id,
'role_id': self.roles.first().id,
'confirm_password': user.password}
# django.test.client doesn't like None fields in forms
for key in list(formData):
if formData[key] is None:
del formData[key]
res = self.client.post(USER_CREATE_URL, formData)
self.assertNoFormErrors(res)
@ -250,6 +262,11 @@ class UsersViewTests(test.BaseAdminViewTests):
'role_id': self.roles.first().id,
'confirm_password': "doesntmatch"}
# django.test.client doesn't like None fields in forms
for key in list(formData):
if formData[key] is None:
del formData[key]
res = self.client.post(USER_CREATE_URL, formData)
self.assertFormError(res, "form", None, ['Passwords do not match.'])
@ -296,6 +313,11 @@ class UsersViewTests(test.BaseAdminViewTests):
'role_id': self.roles.first().id,
'confirm_password': 'four'}
# django.test.client doesn't like None fields in forms
for key in list(formData):
if formData[key] is None:
del formData[key]
res = self.client.post(USER_CREATE_URL, formData)
self.assertFormError(
@ -344,6 +366,11 @@ class UsersViewTests(test.BaseAdminViewTests):
'role_id': self.roles.first().id,
'confirm_password': 'MoreThanEighteenChars'}
# django.test.client doesn't like None fields in forms
for key in list(formData):
if formData[key] is None:
del formData[key]
res = self.client.post(USER_CREATE_URL, formData)
self.assertFormError(

View File

@ -5635,9 +5635,9 @@ class ConsoleManagerTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
self.mock_instance_volume_attach.return_value = None
volume = self.cinder_volumes.list()[1]
# note that 'device' is not passed
form_data = {"volume": volume.id,
"instance_id": server.id,
"device": None}
"instance_id": server.id}
url = reverse('horizon:project:instances:attach_volume',
args=[server.id])
@ -5647,7 +5647,7 @@ class ConsoleManagerTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
self.assertRedirectsNoFollow(res, INDEX_URL)
self.mock_volume_list.assert_called_once_with(helpers.IsHttpRequest())
self.mock_instance_volume_attach.assert_called_once_with(
helpers.IsHttpRequest(), volume.id, server.id, str(None))
helpers.IsHttpRequest(), volume.id, server.id, None)
@mock.patch.object(api.cinder, 'volume_list')
@mock.patch.object(api.cinder, 'volume_get')
@ -5665,9 +5665,9 @@ class ConsoleManagerTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
mock_volume_list.return_value = volumes
mock_volume_get.return_value = volume
# note that 'device' is not passed
form_data = {"volume": volume.id,
"instance_id": server.id,
"device": None}
"instance_id": server.id}
url = reverse('horizon:project:instances:attach_volume',
args=[server.id])
@ -5693,9 +5693,9 @@ class ConsoleManagerTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
mock_volume_list.return_value = volumes
mock_volume_get.return_value = volume
# note that 'device' is not passed
form_data = {"volume": volume.id,
"instance_id": server.id,
"device": None}
"instance_id": server.id}
url = reverse('horizon:project:instances:attach_volume',
args=[server.id])
@ -5724,9 +5724,9 @@ class ConsoleManagerTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
self.mock_get_microversion.return_value = api_versions.APIVersion(
'2.60')
# note that 'device' is not passed
form_data = {"volume": volume.id,
"instance_id": server1.id,
"device": None}
"instance_id": server1.id}
url = reverse('horizon:project:instances:attach_volume',
args=[server1.id])
@ -5734,9 +5734,9 @@ class ConsoleManagerTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
s1 = self.client.post(url, form_data)
self.assertNoFormErrors(s1)
# note that device is not passed
form_data = {"volume": volume.id,
"instance_id": server2.id,
"device": None}
"instance_id": server2.id}
url = reverse('horizon:project:instances:attach_volume',
args=[server2.id])

View File

@ -568,10 +568,10 @@ class SecurityGroupsViewTests(test.TestCase):
self.mock_security_group_list.return_value = sec_group_list
self.mock_is_extension_supported.return_value = True
# note that 'port' is not passed
formData = {'method': 'AddRule',
'id': sec_group.id,
'port_or_range': 'port',
'port': None,
'rule_menu': rule.ip_protocol,
'cidr': rule.ip_range['cidr'],
'remote': 'cidr'}
@ -608,10 +608,10 @@ class SecurityGroupsViewTests(test.TestCase):
self.assertNoMessages()
self.assertContains(res, "greater than or equal to")
# note that 'from_port' is not passed
formData = {'method': 'AddRule',
'id': sec_group.id,
'port_or_range': 'range',
'from_port': None,
'to_port': rule.to_port,
'rule_menu': rule.ip_protocol,
'cidr': rule.ip_range['cidr'],
@ -621,11 +621,11 @@ class SecurityGroupsViewTests(test.TestCase):
self.assertContains(res, cgi.escape('"from" port number is invalid',
quote=True))
# note that 'to_port' is not passed
formData = {'method': 'AddRule',
'id': sec_group.id,
'port_or_range': 'range',
'from_port': rule.from_port,
'to_port': None,
'rule_menu': rule.ip_protocol,
'cidr': rule.ip_range['cidr'],
'remote': 'cidr'}
@ -675,30 +675,6 @@ class SecurityGroupsViewTests(test.TestCase):
self.assertNoMessages()
self.assertContains(res, "The ICMP code not in range (-1, 255)")
formData = {'method': 'AddRule',
'id': sec_group.id,
'port_or_range': 'port',
'icmp_type': icmp_rule.from_port,
'icmp_code': None,
'rule_menu': icmp_rule.ip_protocol,
'cidr': icmp_rule.ip_range['cidr'],
'remote': 'cidr'}
res = self.client.post(self.edit_url, formData)
self.assertNoMessages()
self.assertContains(res, "The ICMP code not in range (-1, 255)")
formData = {'method': 'AddRule',
'id': sec_group.id,
'port_or_range': 'port',
'icmp_type': None,
'icmp_code': icmp_rule.to_port,
'rule_menu': icmp_rule.ip_protocol,
'cidr': icmp_rule.ip_range['cidr'],
'remote': 'cidr'}
res = self.client.post(self.edit_url, formData)
self.assertNoMessages()
self.assertContains(res, "The ICMP type not in range (-1, 255)")
formData = {'method': 'AddRule',
'id': sec_group.id,
'port_or_range': 'port',
@ -713,10 +689,10 @@ class SecurityGroupsViewTests(test.TestCase):
res, "ICMP code is provided but ICMP type is missing.")
self.assert_mock_multiple_calls_with_same_arguments(
self.mock_security_group_list, 10,
self.mock_security_group_list, 6,
mock.call(test.IsHttpRequest()))
self.assert_mock_multiple_calls_with_same_arguments(
self.mock_is_extension_supported, 10,
self.mock_is_extension_supported, 6,
mock.call(test.IsHttpRequest(), 'standard-attr-description'))
@test.create_mocks({api.neutron: ('security_group_rule_create',