def test_is_hyper(self): ''' Test to returns a bool whether or not this node is a hypervisor of any kind ''' with patch.dict(xapi.__grains__, {'virtual_subtype': 'Dom0'}): self.assertFalse(xapi.is_hyper()) with patch.dict(xapi.__grains__, {'virtual': 'Xen Dom0'}): self.assertFalse(xapi.is_hyper()) with patch.dict(xapi.__grains__, {'virtual_subtype': 'Xen Dom0'}): with patch('salt.utils.fopen', mock_open(read_data="salt")): self.assertFalse(xapi.is_hyper()) with patch('salt.utils.fopen', mock_open()) as mock_read: mock_read.side_effect = IOError self.assertFalse(xapi.is_hyper()) with patch('salt.utils.fopen', mock_open(read_data="xen_")): with patch.dict(xapi.__grains__, {'ps': 'salt'}): mock = MagicMock(return_value={'xenstore': 'salt'}) with patch.dict(xapi.__salt__, {'cmd.run': mock}): self.assertTrue(xapi.is_hyper())