def test_allocate_port_range_retry(self, mock_verify, mock_ports): self.config(port_range='10000:10003', group='console') mock_verify.side_effect = (exception.Conflict, exception.Conflict, None) port = console_utils.acquire_port() verify_calls = [mock.call(10000), mock.call(10001), mock.call(10002)] mock_verify.assert_has_calls(verify_calls) self.assertEqual(port, 10002) mock_ports.add.assert_called_once_with(10002)
def test_allocate_port_success(self, mock_verify, mock_ports): self.config(port_range='10000:10001', group='console') port = console_utils.acquire_port() mock_verify.assert_called_once_with(10000) self.assertEqual(port, 10000) mock_ports.add.assert_called_once_with(10000)