Browse Source

Properly mock configdrive building in unit tests

Currently we fail unit tests if genisoimage is not present, e.g. in RDO.

Change-Id: Id241c9625628de101e2ed40d71cb8d4ed06a50ed
Dmitry Tantsur 3 months ago
parent
commit
6c55e2f3e2
1 changed files with 8 additions and 0 deletions
  1. 8
    0
      metalsmith/test/test_provisioner.py

+ 8
- 0
metalsmith/test/test_provisioner.py View File

@@ -268,6 +268,10 @@ class TestProvisionNode(Base):
268 268
                 self.api.network.create_port.return_value.id
269 269
             ],
270 270
         }
271
+        self.configdrive_mock = self.useFixture(
272
+            fixtures.MockPatchObject(_config.InstanceConfig,
273
+                                     'build_configdrive', autospec=True)
274
+        ).mock
271 275
 
272 276
     def test_ok(self):
273 277
         inst = self.pr.provision_node(self.node, 'image',
@@ -283,6 +287,8 @@ class TestProvisionNode(Base):
283 287
         self.api.baremetal.update_node.assert_called_once_with(
284 288
             self.node, instance_info=self.instance_info, extra=self.extra)
285 289
         self.api.baremetal.validate_node.assert_called_once_with(self.node)
290
+        self.configdrive_mock.assert_called_once_with(mock.ANY, self.node,
291
+                                                      self.node.name)
286 292
         self.api.baremetal.set_node_provision_state.assert_called_once_with(
287 293
             self.node, 'active', config_drive=mock.ANY)
288 294
         self.assertFalse(self.api.network.delete_port.called)
@@ -371,6 +377,8 @@ class TestProvisionNode(Base):
371 377
         self.api.baremetal.update_node.assert_called_once_with(
372 378
             self.node, instance_info=self.instance_info, extra=self.extra)
373 379
         self.api.baremetal.validate_node.assert_called_once_with(self.node)
380
+        self.configdrive_mock.assert_called_once_with(mock.ANY, self.node,
381
+                                                      hostname)
374 382
         self.api.baremetal.set_node_provision_state.assert_called_once_with(
375 383
             self.node, 'active', config_drive=mock.ANY)
376 384
         self.assertFalse(

Loading…
Cancel
Save