Browse Source

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

tags/16.0.0.0b2
Zuul 1 week ago
parent
commit
9f4055450f

+ 2
- 2
openstack_dashboard/dashboards/admin/flavors/tests.py View File

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

+ 4
- 4
openstack_dashboard/dashboards/admin/rbac_policies/tests.py View File

@@ -131,9 +131,9 @@ class RBACPolicyTests(test.BaseAdminViewTests):
131 131
         self.mock_network_list.return_value = self.networks.list()
132 132
         self.mock_is_extension_supported.return_value = False
133 133
 
134
+        # note that 'network_id' is not included
134 135
         form_data = {'target_tenant': rbac_policy.target_tenant,
135
-                     'action_object_type': 'external_network',
136
-                     'network_id': None}
136
+                     'action_object_type': 'external_network'}
137 137
         url = reverse('horizon:admin:rbac_policies:create')
138 138
         res = self.client.post(url, form_data)
139 139
 
@@ -161,9 +161,9 @@ class RBACPolicyTests(test.BaseAdminViewTests):
161 161
         self.mock_policy_list.return_value = self.qos_policies.list()
162 162
         self.mock_is_extension_supported.return_value = True
163 163
 
164
+        # note that 'qos_policy_id' is not included
164 165
         form_data = {'target_tenant': rbac_policy.target_tenant,
165
-                     'action_object_type': 'shared_qos_policy',
166
-                     'qos_policy_id': None}
166
+                     'action_object_type': 'shared_qos_policy'}
167 167
         url = reverse('horizon:admin:rbac_policies:create')
168 168
         res = self.client.post(url, form_data)
169 169
 

+ 27
- 0
openstack_dashboard/dashboards/identity/users/tests.py View File

@@ -127,6 +127,12 @@ class UsersViewTests(test.BaseAdminViewTests):
127 127
                     'enabled': True,
128 128
                     'confirm_password': user.password,
129 129
                     'phone_num': phone_number}
130
+
131
+        # django.test.client doesn't like None fields in forms
132
+        for key in list(formData):
133
+            if formData[key] is None:
134
+                del formData[key]
135
+
130 136
         res = self.client.post(USER_CREATE_URL, formData)
131 137
 
132 138
         self.assertNoFormErrors(res)
@@ -195,6 +201,12 @@ class UsersViewTests(test.BaseAdminViewTests):
195 201
                     'project': self.tenant.id,
196 202
                     'role_id': self.roles.first().id,
197 203
                     'confirm_password': user.password}
204
+
205
+        # django.test.client doesn't like None fields in forms
206
+        for key in list(formData):
207
+            if formData[key] is None:
208
+                del formData[key]
209
+
198 210
         res = self.client.post(USER_CREATE_URL, formData)
199 211
 
200 212
         self.assertNoFormErrors(res)
@@ -250,6 +262,11 @@ class UsersViewTests(test.BaseAdminViewTests):
250 262
                     'role_id': self.roles.first().id,
251 263
                     'confirm_password': "doesntmatch"}
252 264
 
265
+        # django.test.client doesn't like None fields in forms
266
+        for key in list(formData):
267
+            if formData[key] is None:
268
+                del formData[key]
269
+
253 270
         res = self.client.post(USER_CREATE_URL, formData)
254 271
 
255 272
         self.assertFormError(res, "form", None, ['Passwords do not match.'])
@@ -296,6 +313,11 @@ class UsersViewTests(test.BaseAdminViewTests):
296 313
                     'role_id': self.roles.first().id,
297 314
                     'confirm_password': 'four'}
298 315
 
316
+        # django.test.client doesn't like None fields in forms
317
+        for key in list(formData):
318
+            if formData[key] is None:
319
+                del formData[key]
320
+
299 321
         res = self.client.post(USER_CREATE_URL, formData)
300 322
 
301 323
         self.assertFormError(
@@ -344,6 +366,11 @@ class UsersViewTests(test.BaseAdminViewTests):
344 366
                     'role_id': self.roles.first().id,
345 367
                     'confirm_password': 'MoreThanEighteenChars'}
346 368
 
369
+        # django.test.client doesn't like None fields in forms
370
+        for key in list(formData):
371
+            if formData[key] is None:
372
+                del formData[key]
373
+
347 374
         res = self.client.post(USER_CREATE_URL, formData)
348 375
 
349 376
         self.assertFormError(

+ 11
- 11
openstack_dashboard/dashboards/project/instances/tests.py View File

@@ -5635,9 +5635,9 @@ class ConsoleManagerTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
5635 5635
         self.mock_instance_volume_attach.return_value = None
5636 5636
         volume = self.cinder_volumes.list()[1]
5637 5637
 
5638
+        # note that 'device' is not passed
5638 5639
         form_data = {"volume": volume.id,
5639
-                     "instance_id": server.id,
5640
-                     "device": None}
5640
+                     "instance_id": server.id}
5641 5641
 
5642 5642
         url = reverse('horizon:project:instances:attach_volume',
5643 5643
                       args=[server.id])
@@ -5647,7 +5647,7 @@ class ConsoleManagerTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
5647 5647
         self.assertRedirectsNoFollow(res, INDEX_URL)
5648 5648
         self.mock_volume_list.assert_called_once_with(helpers.IsHttpRequest())
5649 5649
         self.mock_instance_volume_attach.assert_called_once_with(
5650
-            helpers.IsHttpRequest(), volume.id, server.id, str(None))
5650
+            helpers.IsHttpRequest(), volume.id, server.id, None)
5651 5651
 
5652 5652
     @mock.patch.object(api.cinder, 'volume_list')
5653 5653
     @mock.patch.object(api.cinder, 'volume_get')
@@ -5665,9 +5665,9 @@ class ConsoleManagerTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
5665 5665
         mock_volume_list.return_value = volumes
5666 5666
         mock_volume_get.return_value = volume
5667 5667
 
5668
+        # note that 'device' is not passed
5668 5669
         form_data = {"volume": volume.id,
5669
-                     "instance_id": server.id,
5670
-                     "device": None}
5670
+                     "instance_id": server.id}
5671 5671
 
5672 5672
         url = reverse('horizon:project:instances:attach_volume',
5673 5673
                       args=[server.id])
@@ -5693,9 +5693,9 @@ class ConsoleManagerTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
5693 5693
         mock_volume_list.return_value = volumes
5694 5694
         mock_volume_get.return_value = volume
5695 5695
 
5696
+        # note that 'device' is not passed
5696 5697
         form_data = {"volume": volume.id,
5697
-                     "instance_id": server.id,
5698
-                     "device": None}
5698
+                     "instance_id": server.id}
5699 5699
 
5700 5700
         url = reverse('horizon:project:instances:attach_volume',
5701 5701
                       args=[server.id])
@@ -5724,9 +5724,9 @@ class ConsoleManagerTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
5724 5724
         self.mock_get_microversion.return_value = api_versions.APIVersion(
5725 5725
             '2.60')
5726 5726
 
5727
+        # note that 'device' is not passed
5727 5728
         form_data = {"volume": volume.id,
5728
-                     "instance_id": server1.id,
5729
-                     "device": None}
5729
+                     "instance_id": server1.id}
5730 5730
 
5731 5731
         url = reverse('horizon:project:instances:attach_volume',
5732 5732
                       args=[server1.id])
@@ -5734,9 +5734,9 @@ class ConsoleManagerTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
5734 5734
         s1 = self.client.post(url, form_data)
5735 5735
         self.assertNoFormErrors(s1)
5736 5736
 
5737
+        # note that device is not passed
5737 5738
         form_data = {"volume": volume.id,
5738
-                     "instance_id": server2.id,
5739
-                     "device": None}
5739
+                     "instance_id": server2.id}
5740 5740
 
5741 5741
         url = reverse('horizon:project:instances:attach_volume',
5742 5742
                       args=[server2.id])

+ 5
- 29
openstack_dashboard/dashboards/project/security_groups/tests.py View File

@@ -568,10 +568,10 @@ class SecurityGroupsViewTests(test.TestCase):
568 568
         self.mock_security_group_list.return_value = sec_group_list
569 569
         self.mock_is_extension_supported.return_value = True
570 570
 
571
+        # note that 'port' is not passed
571 572
         formData = {'method': 'AddRule',
572 573
                     'id': sec_group.id,
573 574
                     'port_or_range': 'port',
574
-                    'port': None,
575 575
                     'rule_menu': rule.ip_protocol,
576 576
                     'cidr': rule.ip_range['cidr'],
577 577
                     'remote': 'cidr'}
@@ -608,10 +608,10 @@ class SecurityGroupsViewTests(test.TestCase):
608 608
         self.assertNoMessages()
609 609
         self.assertContains(res, "greater than or equal to")
610 610
 
611
+        # note that 'from_port' is not passed
611 612
         formData = {'method': 'AddRule',
612 613
                     'id': sec_group.id,
613 614
                     'port_or_range': 'range',
614
-                    'from_port': None,
615 615
                     'to_port': rule.to_port,
616 616
                     'rule_menu': rule.ip_protocol,
617 617
                     'cidr': rule.ip_range['cidr'],
@@ -621,11 +621,11 @@ class SecurityGroupsViewTests(test.TestCase):
621 621
         self.assertContains(res, cgi.escape('"from" port number is invalid',
622 622
                                             quote=True))
623 623
 
624
+        # note that 'to_port' is not passed
624 625
         formData = {'method': 'AddRule',
625 626
                     'id': sec_group.id,
626 627
                     'port_or_range': 'range',
627 628
                     'from_port': rule.from_port,
628
-                    'to_port': None,
629 629
                     'rule_menu': rule.ip_protocol,
630 630
                     'cidr': rule.ip_range['cidr'],
631 631
                     'remote': 'cidr'}
@@ -675,30 +675,6 @@ class SecurityGroupsViewTests(test.TestCase):
675 675
         self.assertNoMessages()
676 676
         self.assertContains(res, "The ICMP code not in range (-1, 255)")
677 677
 
678
-        formData = {'method': 'AddRule',
679
-                    'id': sec_group.id,
680
-                    'port_or_range': 'port',
681
-                    'icmp_type': icmp_rule.from_port,
682
-                    'icmp_code': None,
683
-                    'rule_menu': icmp_rule.ip_protocol,
684
-                    'cidr': icmp_rule.ip_range['cidr'],
685
-                    'remote': 'cidr'}
686
-        res = self.client.post(self.edit_url, formData)
687
-        self.assertNoMessages()
688
-        self.assertContains(res, "The ICMP code not in range (-1, 255)")
689
-
690
-        formData = {'method': 'AddRule',
691
-                    'id': sec_group.id,
692
-                    'port_or_range': 'port',
693
-                    'icmp_type': None,
694
-                    'icmp_code': icmp_rule.to_port,
695
-                    'rule_menu': icmp_rule.ip_protocol,
696
-                    'cidr': icmp_rule.ip_range['cidr'],
697
-                    'remote': 'cidr'}
698
-        res = self.client.post(self.edit_url, formData)
699
-        self.assertNoMessages()
700
-        self.assertContains(res, "The ICMP type not in range (-1, 255)")
701
-
702 678
         formData = {'method': 'AddRule',
703 679
                     'id': sec_group.id,
704 680
                     'port_or_range': 'port',
@@ -713,10 +689,10 @@ class SecurityGroupsViewTests(test.TestCase):
713 689
             res, "ICMP code is provided but ICMP type is missing.")
714 690
 
715 691
         self.assert_mock_multiple_calls_with_same_arguments(
716
-            self.mock_security_group_list, 10,
692
+            self.mock_security_group_list, 6,
717 693
             mock.call(test.IsHttpRequest()))
718 694
         self.assert_mock_multiple_calls_with_same_arguments(
719
-            self.mock_is_extension_supported, 10,
695
+            self.mock_is_extension_supported, 6,
720 696
             mock.call(test.IsHttpRequest(), 'standard-attr-description'))
721 697
 
722 698
     @test.create_mocks({api.neutron: ('security_group_rule_create',

Loading…
Cancel
Save