def test_pci_passthrough_with_pci_stats_none(self): request = objects.ContainerPCIRequest( count=1, spec=[{'vendor_id': '8086'}]) requests = objects.ContainerPCIRequests(requests=[request]) container = objects.Container(self.context) host = HostState('testhost') host.pci_stats = None extra_spec = {'pci_requests': requests} self.assertFalse(self.filt_cls.host_passes(host, container, extra_spec))
def test_pci_passthrough_pass(self): pci_stats_mock = mock.MagicMock() pci_stats_mock.support_requests.return_value = True request = objects.ContainerPCIRequest( count=1, spec=[{'vendor_id': '8086'}]) requests = objects.ContainerPCIRequests(requests=[request]) container = objects.Container(self.context) host = HostState('testhost') host.pci_stats = pci_stats_mock extra_spec = {'pci_requests': requests} self.assertTrue(self.filt_cls.host_passes(host, container, extra_spec)) pci_stats_mock.support_requests.assert_called_once_with( requests.requests)