コード例 #1
0
 def test_detach(self, mock_detach):
     plg = extension.Extension(name="demo",
                               entry_point="os-acc",
                               plugin=DemoPlugin,
                               obj=None)
     with mock.patch('stevedore.extension.ExtensionManager.names',
                     return_value=['foobar']),\
             mock.patch('stevedore.extension.ExtensionManager.__getitem__',
                        return_value=plg):
         os_acc.initialize()
         fake_acc = {
             "instance_uuid": "",
             "interface_type": "demo",
             "name": "NVIDIA Corporation GP100GL",
             "address": "0000:81:00.0"
         }
         fake_instance = {}
         fake_inst_type = {}
         fake_guest = ""
         fake_host = ""
         os_acc.detach(fake_acc, fake_guest, fake_host, fake_instance,
                       fake_inst_type)
         mock_detach.assert_called_once_with(fake_acc, fake_guest,
                                             fake_host, fake_instance,
                                             fake_inst_type)
コード例 #2
0
ファイル: test_pci.py プロジェクト: SeanMooney/os-acc
    def detach_pci_device(self, mock_detach):
        os_acc.initialize(reset=True)
        fake_acc = {
            "instance_uuid": "",
            "type": "pci",
            "name": "NVIDIA Corporation GP100GL",
            "pcie_address": "0000:81:00.0"
        }

        class FakeGuest(object):
            def attach_device(self, conf, persistent, live):
                pass

            def detach_device(self, conf, persistent, live):
                pass

            def get_power_state(self, host):
                pass

        fake_instance = {}
        fake_inst_type = {}
        fake_guest = FakeGuest()
        fake_host = ""
        os_acc.detach(fake_acc, fake_guest, fake_host, fake_instance,
                      fake_inst_type)
        mock_detach.assert_called_once_with(fake_acc, fake_guest, fake_host,
                                            fake_instance, fake_inst_type)
コード例 #3
0
 def test_initialize(self, mock_EM):
     self.assertIsNone(os_acc._EXT_MANAGER)
     # Note: the duplicate call for initialize is to validate
     # that the extension manager is only initialized once
     os_acc.initialize()
     os_acc.initialize()
     mock_EM.assert_called_once_with(invoke_on_load=False,
                                     namespace='os_acc')
     self.assertIsNotNone(os_acc._EXT_MANAGER)