Browse Source

Merge "Use assertIsNone instead of assertEqual(None, obj)"

changes/67/433667/32
Jenkins 2 years ago
parent
commit
7aa506469b

+ 1
- 1
nailgun/nailgun/extensions/network_manager/tests/test_network_manager.py View File

@@ -464,7 +464,7 @@ class TestNetworkManager(BaseIntegrationTest):
464 464
         admin_net1 = objects.NetworkGroup.get_admin_network_group(node=node0)
465 465
         admin_net2 = objects.NetworkGroup.get_admin_network_group(node=node1)
466 466
 
467
-        self.assertEqual(admin_net1.group_id, None)
467
+        self.assertIsNone(admin_net1.group_id)
468 468
         self.assertEqual(admin_net2.group_id, node_group.json_body['id'])
469 469
 
470 470
     def test_get_admin_network_group_with_admin_net(self):

+ 2
- 2
nailgun/nailgun/extensions/network_manager/tests/test_node_nic_handlers_w_bonding.py View File

@@ -320,7 +320,7 @@ class TestNodeNICsBonding(BaseIntegrationTest):
320 320
         )
321 321
         self.assertEqual(200, resp.status_code)
322 322
 
323
-        self.assertEqual(node.cluster, None)
323
+        self.assertIsNone(node.cluster)
324 324
         resp = self.env.node_nics_get(node.id)
325 325
         self.assertEqual(resp.status_code, 200)
326 326
 
@@ -341,7 +341,7 @@ class TestNodeNICsBonding(BaseIntegrationTest):
341 341
         )
342 342
         self.assertEqual(resp.status_code, 200)
343 343
 
344
-        self.assertEqual(node.cluster, None)
344
+        self.assertIsNone(node.cluster)
345 345
         resp = self.env.node_nics_get(node.id)
346 346
         self.assertEqual(resp.status_code, 200)
347 347
 

+ 3
- 3
nailgun/nailgun/test/integration/test_cluster_handler.py View File

@@ -179,8 +179,8 @@ class TestHandlers(BaseIntegrationTest):
179 179
         self.assertEqual(self.db.query(Node).count(), 2)
180 180
         for node in self.db.query(Node):
181 181
             self.assertEqual(node.status, 'discover')
182
-            self.assertEqual(node.cluster_id, None)
183
-            self.assertEqual(node.group_id, None)
182
+            self.assertIsNone(node.cluster_id)
183
+            self.assertIsNone(node.group_id)
184 184
             self.assertEqual(node.roles, [])
185 185
             self.assertFalse(node.pending_deletion)
186 186
             self.assertFalse(node.pending_addition)
@@ -201,7 +201,7 @@ class TestHandlers(BaseIntegrationTest):
201 201
 
202 202
         node = self.db.query(Node).first()
203 203
         self.assertEqual(node.status, 'discover')
204
-        self.assertEqual(node.cluster_id, None)
204
+        self.assertIsNone(node.cluster_id)
205 205
 
206 206
     def test_cluster_deletion_delete_networks(self):
207 207
         cluster = self.env.create_cluster(api=True)

+ 2
- 2
nailgun/nailgun/test/integration/test_node_collection_handlers.py View File

@@ -428,7 +428,7 @@ class TestHandlers(BaseIntegrationTest):
428 428
             expect_http=400,
429 429
             expected_error="No mac address specified"
430 430
         )
431
-        self.assertEqual(node, None)
431
+        self.assertIsNone(node)
432 432
 
433 433
     def test_node_create_with_invalid_disk_model(self):
434 434
         meta = self.env.default_metadata()
@@ -534,7 +534,7 @@ class TestHandlers(BaseIntegrationTest):
534 534
         self.assertEqual(1, len(resp.json_body))
535 535
         self.assertEqual(node.id, resp.json_body[0]['id'])
536 536
         self.assertEqual(node.name, node_name)
537
-        self.assertEqual(node.cluster, None)
537
+        self.assertIsNone(node.cluster)
538 538
         self.assertEqual(node.pending_roles, [])
539 539
 
540 540
     def test_discovered_node_unified_name(self):

+ 1
- 1
nailgun/nailgun/test/integration/test_task_managers.py View File

@@ -1039,7 +1039,7 @@ class TestTaskManagers(BaseIntegrationTest):
1039 1039
 
1040 1040
         for node in q_nodes:
1041 1041
             self.assertEqual(node.status, 'discover')
1042
-            self.assertEqual(node.cluster_id, None)
1042
+            self.assertIsNone(node.cluster_id)
1043 1043
 
1044 1044
     @fake_tasks(recover_offline_nodes=False)
1045 1045
     def test_deletion_offline_node_when_cluster_has_only_one_node(self):

+ 3
- 3
nailgun/nailgun/test/unit/fuyaql_tests/test_fuyaql.py View File

@@ -163,7 +163,7 @@ class TestFuyaqlController(base.BaseUnitTest):
163 163
         self.assertRaises(self.controller.evaluate('changed($.roles)'))
164 164
 
165 165
     def test_get_task(self, obj_mock):
166
-        self.assertEqual(self.controller._get_task(None), None)
166
+        self.assertIsNone(self.controller._get_task(None))
167 167
 
168 168
         obj_mock.Transaction.get_by_uid.return_value = None
169 169
         self.assertFalse(self.controller._get_task(1))
@@ -214,13 +214,13 @@ class TestFuyaqlController(base.BaseUnitTest):
214 214
             {'1': {'a': 2}},
215 215
             self.controller._infos[self.controller.EXPECTED],
216 216
         )
217
-        self.assertEqual(self.controller._node_id, None)
217
+        self.assertIsNone(self.controller._node_id)
218 218
 
219 219
         self.controller._node_id = 8
220 220
         self.controller._set_info(self.controller.EXPECTED, None)
221 221
         self.assertEqual(self.controller._infos[self.controller.EXPECTED],
222 222
                          self.new_context)
223
-        self.assertEqual(self.controller._node_id, None)
223
+        self.assertIsNone(self.controller._node_id)
224 224
 
225 225
         serialized.assert_called_once_with(
226 226
             self.controller._cluster,

+ 2
- 2
nailgun/nailgun/test/unit/test_downgrade_fuel_9_2.py View File

@@ -299,7 +299,7 @@ class TestAttributesDowngrade(base.BaseAlembicMigrationTest):
299 299
         for editable in results:
300 300
             editable = jsonutils.loads(editable[0])
301 301
             common = editable.setdefault('common', {})
302
-            self.assertEqual(common.get('security_groups'), None)
302
+            self.assertIsNone(common.get('security_groups'))
303 303
 
304 304
     def test_release_attributes_downgrade(self):
305 305
         releases = self.meta.tables['releases']
@@ -308,7 +308,7 @@ class TestAttributesDowngrade(base.BaseAlembicMigrationTest):
308 308
         for attrs in results:
309 309
             attrs = jsonutils.loads(attrs[0])
310 310
             common = attrs.setdefault('editable', {}).setdefault('common', {})
311
-            self.assertEqual(common.get('security_groups'), None)
311
+            self.assertIsNone(common.get('security_groups'))
312 312
 
313 313
 
314 314
 class TestTags(base.BaseAlembicMigrationTest):

+ 2
- 2
nailgun/nailgun/test/unit/test_migration_fuel_9_2.py View File

@@ -624,7 +624,7 @@ class TestAttributesUpdate(base.BaseAlembicMigrationTest):
624 624
         for attrs in results:
625 625
             attrs = jsonutils.loads(attrs[0])
626 626
             common = attrs.setdefault('editable', {}).setdefault('common', {})
627
-            self.assertEqual(common.get('security_groups'), None)
627
+            self.assertIsNone(common.get('security_groups'))
628 628
 
629 629
     def test_cluster_attributes_update(self):
630 630
         clusters_attributes = self.meta.tables['attributes']
@@ -654,7 +654,7 @@ class TestAttributesUpdate(base.BaseAlembicMigrationTest):
654 654
         for editable in results:
655 655
             editable = jsonutils.loads(editable[0])
656 656
             common = editable.setdefault('common', {})
657
-            self.assertEqual(common.get('security_groups'), None)
657
+            self.assertIsNone(common.get('security_groups'))
658 658
 
659 659
     def test_upgrade_release_with_nic_attributes(self):
660 660
         releases_table = self.meta.tables['releases']

+ 1
- 1
nailgun/nailgun/test/unit/test_migration_plugins_cluster_attrs_use_ids_mapping.py View File

@@ -63,5 +63,5 @@ class TestMigrationPluginsClusterAttrs(BaseTestCase):
63 63
         connection = self.db.connection()
64 64
         upgrade_6_0_to_6_1_plugins_cluster_attrs_use_ids_mapping(connection)
65 65
         plugin_attr = self.cluster.attributes.editable['some_plugin_name']
66
-        self.assertEqual(plugin_attr['metadata']['plugin_id'], None)
66
+        self.assertIsNone(plugin_attr['metadata']['plugin_id'])
67 67
         self.assertNotIn('plugin_version', plugin_attr['metadata'])

+ 3
- 3
nailgun/nailgun/test/unit/test_node_assignment_handler.py View File

@@ -56,7 +56,7 @@ class TestAssignmentHandlers(BaseIntegrationTest):
56 56
         ]
57 57
         resp = self._assign_roles(assignment_data)
58 58
         self.assertEqual(200, resp.status_code)
59
-        self.assertEqual(None, resp.json_body)
59
+        self.assertIsNone(resp.json_body)
60 60
         self.assertEqual(node.cluster, self.cluster)
61 61
         self.datadiff(
62 62
             node.pending_roles,
@@ -82,8 +82,8 @@ class TestAssignmentHandlers(BaseIntegrationTest):
82 82
             headers=self.default_headers
83 83
         )
84 84
         self.assertEqual(200, resp.status_code)
85
-        self.assertEqual(None, resp.json_body)
86
-        self.assertEqual(node.cluster, None)
85
+        self.assertIsNone(resp.json_body)
86
+        self.assertIsNone(node.cluster)
87 87
         self.assertEqual(node.pending_roles, [])
88 88
         self.assertEqual(node.pending_addition, False)
89 89
 

+ 1
- 1
nailgun/nailgun/test/unit/test_objects.py View File

@@ -465,7 +465,7 @@ class TestNodeObject(BaseIntegrationTest):
465 465
         node2_db = self.env.create_node()
466 466
         objects.Node.remove_from_cluster(node_db)
467 467
         self.db().refresh(config)
468
-        self.assertEqual(node_db.cluster_id, None)
468
+        self.assertIsNone(node_db.cluster_id)
469 469
         self.assertEqual(node_db.roles, [])
470 470
         self.assertEqual(node_db.pending_roles, [])
471 471
         self.assertFalse(config.is_active)

Loading…
Cancel
Save