# Path: ironicclient/exc.py
# class AmbiguousAuthSystem(exceptions.ClientException):
# class InvalidAttribute(exceptions.ClientException):
# class StateTransitionFailed(exceptions.ClientException):
# class StateTransitionTimeout(exceptions.ClientException):
# def from_response(response, message=None, traceback=None, method=None,
#                   url=None):
# 
# Path: ironicclient/tests/unit/utils.py
# class BaseTestCase(testtools.TestCase):
# class FakeAPI(object):
# class FakeConnection(object):
# class FakeResponse(object):
#     def setUp(self):
#     def __init__(self, responses, path_prefix=None):
#     def _request(self, method, url, headers=None, body=None, params=None):
#     def raw_request(self, *args, **kwargs):
#     def json_request(self, *args, **kwargs):
#     def __init__(self, response=None, path_prefix=None):
#     def request(self, method, conn_url, **kwargs):
#     def setresponse(self, response):
#     def getresponse(self):
#     def __repr__(self):
#     def __init__(self, headers, body=None, version=None, status=None,
#                  reason=None, request_headers={}):
#     def getheaders(self):
#     def getheader(self, key, default):
#     def read(self, amt):
#     def __repr__(self):
# def mockSessionResponse(headers, content=None, status_code=None, version=None,
#                         request_headers={}):
# def mockSession(headers, content=None, status_code=None, version=None):


import copy
import testtools
import ironicclient.v1.allocation
from unittest import mock
from ironicclient import exc
from ironicclient.tests.unit import utils
    def setUp(self):
        super(AllocationWaitTest, self).setUp()
        self.mgr = ironicclient.v1.allocation.AllocationManager(mock.Mock())

    def _fake_allocation(self, state, error=None):
        return mock.Mock(state=state, last_error=error)

    def test_success(self, mock_get, mock_sleep):
        allocations = [
            self._fake_allocation('allocating'),
            self._fake_allocation('allocating'),
            self._fake_allocation('active'),
        ]
        mock_get.side_effect = allocations

        result = self.mgr.wait('alloc1')
        self.assertIs(result, allocations[2])
        self.assertEqual(3, mock_get.call_count)
        self.assertEqual(2, mock_sleep.call_count)
        mock_get.assert_called_with(
            self.mgr, 'alloc1', os_ironic_api_version=None,
            global_request_id=None)

    def test_error(self, mock_get, mock_sleep):
        allocations = [
            self._fake_allocation('allocating'),
            self._fake_allocation('error'),
        ]
        mock_get.side_effect = allocations


# Path: ironicclient/exc.py
# class AmbiguousAuthSystem(exceptions.ClientException):
# class InvalidAttribute(exceptions.ClientException):
# class StateTransitionFailed(exceptions.ClientException):
# class StateTransitionTimeout(exceptions.ClientException):
# def from_response(response, message=None, traceback=None, method=None,
#                   url=None):
# 
# Path: ironicclient/tests/unit/utils.py
# class BaseTestCase(testtools.TestCase):
# class FakeAPI(object):
# class FakeConnection(object):
# class FakeResponse(object):
#     def setUp(self):
#     def __init__(self, responses, path_prefix=None):
#     def _request(self, method, url, headers=None, body=None, params=None):
#     def raw_request(self, *args, **kwargs):
#     def json_request(self, *args, **kwargs):
#     def __init__(self, response=None, path_prefix=None):
#     def request(self, method, conn_url, **kwargs):
#     def setresponse(self, response):
#     def getresponse(self):
#     def __repr__(self):
#     def __init__(self, headers, body=None, version=None, status=None,
#                  reason=None, request_headers={}):
#     def getheaders(self):
#     def getheader(self, key, default):
#     def read(self, amt):
#     def __repr__(self):
# def mockSessionResponse(headers, content=None, status_code=None, version=None,
#                         request_headers={}):
# def mockSession(headers, content=None, status_code=None, version=None):


# Path: ironicclient/tests/unit/v1/test_allocation.py
import copy
import testtools
import ironicclient.v1.allocation
from unittest import mock
from ironicclient import exc
from ironicclient.tests.unit import utils

    def setUp(self):
        super(AllocationWaitTest, self).setUp()
        self.mgr = ironicclient.v1.allocation.AllocationManager(mock.Mock())

    def _fake_allocation(self, state, error=None):
        return mock.Mock(state=state, last_error=error)

    def test_success(self, mock_get, mock_sleep):
        allocations = [
            self._fake_allocation('allocating'),
            self._fake_allocation('allocating'),
            self._fake_allocation('active'),
        ]
        mock_get.side_effect = allocations

        result = self.mgr.wait('alloc1')
        self.assertIs(result, allocations[2])
        self.assertEqual(3, mock_get.call_count)
        self.assertEqual(2, mock_sleep.call_count)
        mock_get.assert_called_with(
            self.mgr, 'alloc1', os_ironic_api_version=None,
            global_request_id=None)

    def test_error(self, mock_get, mock_sleep):
        allocations = [
            self._fake_allocation('allocating'),
            self._fake_allocation('error'),
        ]
        mock_get.side_effect = allocations


        self.assertRaises(exc.StateTransitionFailed,