def test_pair(self):
        mock = MagicMock(side_effect=[False, True, True])
        with patch.object(salt.utils.validate.net, 'mac', mock):
            self.assertRaises(CommandExecutionError,
                              bluez.pair, "DE:AD:BE:EF:CA:FE", "1234")

            self.assertRaises(CommandExecutionError,
                              bluez.pair, "DE:AD:BE:EF:CA:FE", "abcd")

            mock = MagicMock(return_value={'device': 'hci0'})
            with patch.object(bluez, 'address_', mock):
                mock = MagicMock(return_value="Ok")
                with patch.dict(bluez.__salt__, {'cmd.run': mock}):
                    self.assertListEqual(bluez.
                                         pair("DE:AD:BE:EF:CA:FE", "1234"),
                                         ["Ok"])
Ensures that instance duplicates raises ApiError
dataset/ETHPy150Open saltstack/salt/tests/unit/modules/bluez_test.py/BluezTestCase.test_pair--crossover with--dataset/ETHPy150Open nii-cloud/dodai-compute/nova/tests/test_instance_types.py/InstanceTypeTestCase.test_repeated_inst_types_should_raise_api_error