# Path: heatclient/common/event_utils.py
# def get_hook_events(hc, stack_id, event_args, nested_depth=0,
#                     hook_type='pre-create'):
# def get_events(hc, stack_id, event_args, nested_depth=0,
#                marker=None, limit=None):
# def _get_nested_ids(hc, stack_id):
# def _get_nested_events(hc, nested_depth, stack_id, event_args):
# def _get_stack_name_from_links(event):
# def _get_stack_events(hc, stack_id, event_args):
# def poll_for_events(hc, stack_name, action=None, poll_period=5, marker=None,
#                     out=None, nested_depth=0):
#     def is_stack_event(event):
# def wait_for_events(ws, stack_name, out=None):
# 
# Path: heatclient/v1/events.py
# DEFAULT_PAGE_SIZE = 20
# class Event(base.Resource):
# class EventManager(stacks.StackChildManager):
#     def __repr__(self):
#     def update(self, **fields):
#     def delete(self):
#     def data(self, **kwargs):
#     def list(self, stack_id, resource_name=None, **kwargs):
#     def get(self, stack_id, resource_name, event_id):
# 
# Path: heatclient/v1/resources.py
# DEFAULT_PAGE_SIZE = 20
# class Resource(base.Resource):
# class ResourceManager(stacks.StackChildManager):
#     def __repr__(self):
#     def update(self, **fields):
#     def delete(self):
#     def data(self, **kwargs):
#     def stack_name(self):
#     def list(self, stack_id, **kwargs):
#     def get(self, stack_id, resource_name, with_attr=None):
#     def metadata(self, stack_id, resource_name):
#     def signal(self, stack_id, resource_name, data=None):
#     def mark_unhealthy(self, stack_id, resource_name,
#                        mark_unhealthy, resource_status_reason):
#     def generate_template(self, resource_name):


from unittest import mock
from heatclient.common import event_utils
from heatclient.v1 import events as hc_ev
from heatclient.v1 import resources as hc_res
import testtools

    def test_get_nested_events(self):
        resources = {'parent': self._mock_resource('resource1', 'foo/child1'),
                     'foo/child1': self._mock_resource('res_child1',
                                                       'foo/child2'),
                     'foo/child2': self._mock_resource('res_child2',
                                                       'foo/child3'),
                     'foo/child3': self._mock_resource('res_child3',
                                                       'foo/END')}

        def resource_list_stub(stack_id):
            return [resources[stack_id]]
        mock_client = mock.MagicMock()
        mock_client.resources.list.side_effect = resource_list_stub

        events = {'foo/child1': self._mock_event('event1', 'res_child1'),
                  'foo/child2': self._mock_event('event2', 'res_child2'),
                  'foo/child3': self._mock_event('event3', 'res_child3')}

        def event_list_stub(stack_id, argfoo):
            return [events[stack_id]]
        mock_client.events.list.side_effect = event_list_stub

        ev_args = {'argfoo': 123}
        # Check nested_depth=1 (non recursive)..
        evs = event_utils._get_nested_events(hc=mock_client,
                                             nested_depth=1,
                                             stack_id='parent',
                                             event_args=ev_args)


# Path: heatclient/common/event_utils.py
# def get_hook_events(hc, stack_id, event_args, nested_depth=0,
#                     hook_type='pre-create'):
# def get_events(hc, stack_id, event_args, nested_depth=0,
#                marker=None, limit=None):
# def _get_nested_ids(hc, stack_id):
# def _get_nested_events(hc, nested_depth, stack_id, event_args):
# def _get_stack_name_from_links(event):
# def _get_stack_events(hc, stack_id, event_args):
# def poll_for_events(hc, stack_name, action=None, poll_period=5, marker=None,
#                     out=None, nested_depth=0):
#     def is_stack_event(event):
# def wait_for_events(ws, stack_name, out=None):
# 
# Path: heatclient/v1/events.py
# DEFAULT_PAGE_SIZE = 20
# class Event(base.Resource):
# class EventManager(stacks.StackChildManager):
#     def __repr__(self):
#     def update(self, **fields):
#     def delete(self):
#     def data(self, **kwargs):
#     def list(self, stack_id, resource_name=None, **kwargs):
#     def get(self, stack_id, resource_name, event_id):
# 
# Path: heatclient/v1/resources.py
# DEFAULT_PAGE_SIZE = 20
# class Resource(base.Resource):
# class ResourceManager(stacks.StackChildManager):
#     def __repr__(self):
#     def update(self, **fields):
#     def delete(self):
#     def data(self, **kwargs):
#     def stack_name(self):
#     def list(self, stack_id, **kwargs):
#     def get(self, stack_id, resource_name, with_attr=None):
#     def metadata(self, stack_id, resource_name):
#     def signal(self, stack_id, resource_name, data=None):
#     def mark_unhealthy(self, stack_id, resource_name,
#                        mark_unhealthy, resource_status_reason):
#     def generate_template(self, resource_name):


# Path: heatclient/tests/unit/test_event_utils.py
from unittest import mock
from heatclient.common import event_utils
from heatclient.v1 import events as hc_ev
from heatclient.v1 import resources as hc_res
import testtools


    def test_get_nested_events(self):
        resources = {'parent': self._mock_resource('resource1', 'foo/child1'),
                     'foo/child1': self._mock_resource('res_child1',
                                                       'foo/child2'),
                     'foo/child2': self._mock_resource('res_child2',
                                                       'foo/child3'),
                     'foo/child3': self._mock_resource('res_child3',
                                                       'foo/END')}

        def resource_list_stub(stack_id):
            return [resources[stack_id]]
        mock_client = mock.MagicMock()
        mock_client.resources.list.side_effect = resource_list_stub

        events = {'foo/child1': self._mock_event('event1', 'res_child1'),
                  'foo/child2': self._mock_event('event2', 'res_child2'),
                  'foo/child3': self._mock_event('event3', 'res_child3')}

        def event_list_stub(stack_id, argfoo):
            return [events[stack_id]]
        mock_client.events.list.side_effect = event_list_stub

        ev_args = {'argfoo': 123}
        # Check nested_depth=1 (non recursive)..
        evs = event_utils._get_nested_events(hc=mock_client,
                                             nested_depth=1,
                                             stack_id='parent',
                                             event_args=ev_args)


        rsrc_calls = [mock.call(stack_id='parent')]