def test_freecpu(self): ''' Test to return an int representing the number of unallocated cpus on this hypervisor ''' mock = MagicMock(return_value={'free_cpus': 1024}) with patch.object(xapi, "node_info", mock): self.assertEqual(xapi.freecpu(), 1024)