Пример #1
0
 def test_list_event_with_kwargs(self):
     stack_id = 'teststack',
     resource_name = 'testresource'
     kwargs = {'limit': 2,
               'marker': '6d6935f4-0ae5',
               'filters': {
                   'resource_action': 'CREATE',
                   'resource_status': 'COMPLETE'
               }}
     manager = events.EventManager(None)
     self.m.StubOutWithMock(manager, '_resolve_stack_id')
     manager._resolve_stack_id(stack_id).AndReturn('teststack/abcd1234')
     self.m.ReplayAll()
     manager._list = mock.MagicMock()
     manager.list(stack_id, resource_name, **kwargs)
     # Make sure url is correct.
     self.assertEqual(1, manager._list.call_count)
     args = manager._list.call_args
     self.assertEqual(2, len(args[0]))
     url, param = args[0]
     self.assertEqual("events", param)
     base_url, query_params = utils.parse_query_url(url)
     expected_base_url = ('/stacks/teststack%2Fabcd1234/'
                          'resources/testresource/events')
     self.assertEqual(expected_base_url, base_url)
     expected_query_dict = {'marker': ['6d6935f4-0ae5'],
                            'limit': ['2'],
                            'resource_action': ['CREATE'],
                            'resource_status': ['COMPLETE']}
     self.assertEqual(expected_query_dict, query_params)
Пример #2
0
    def test_list_event_with_kwargs(self):
        stack_id = 'teststack',
        resource_name = 'testresource'
        kwargs = {'limit': 2,
                  'marker': '6d6935f4-0ae5',
                  'filters': {
                      'resource_action': 'CREATE',
                      'resource_status': 'COMPLETE'
                  }}
        manager = events.EventManager(None)
        manager = events.EventManager(None)
        with mock.patch('heatclient.v1.events.EventManager._resolve_stack_id')\
                as mock_re:
            mock_re.return_value = 'teststack/abcd1234'

            manager._list = mock.MagicMock()
            manager.list(stack_id, resource_name, **kwargs)
            # Make sure url is correct.
            self.assertEqual(1, manager._list.call_count)
            args = manager._list.call_args
            self.assertEqual(2, len(args[0]))
            url, param = args[0]
            self.assertEqual("events", param)
            base_url, query_params = utils.parse_query_url(url)
            expected_base_url = ('/stacks/teststack/abcd1234/'
                                 'resources/testresource/events')
            self.assertEqual(expected_base_url, base_url)
            expected_query_dict = {'marker': ['6d6935f4-0ae5'],
                                   'limit': ['2'],
                                   'resource_action': ['CREATE'],
                                   'resource_status': ['COMPLETE']}
            self.assertEqual(expected_query_dict, query_params)
            mock_re.assert_called_once_with(stack_id)
Пример #3
0
    def test_list_event_with_kwargs(self):
        stack_id = 'teststack',
        resource_name = 'testresource'
        kwargs = {'limit': 2,
                  'marker': '6d6935f4-0ae5',
                  'filters': {
                      'resource_action': 'CREATE',
                      'resource_status': 'COMPLETE'
                  }}
        manager = events.EventManager(None)
        manager = events.EventManager(None)
        with mock.patch('heatclient.v1.events.EventManager._resolve_stack_id')\
                as mock_re:
            mock_re.return_value = 'teststack/abcd1234'

            manager._list = mock.MagicMock()
            manager.list(stack_id, resource_name, **kwargs)
            # Make sure url is correct.
            self.assertEqual(1, manager._list.call_count)
            args = manager._list.call_args
            self.assertEqual(2, len(args[0]))
            url, param = args[0]
            self.assertEqual("events", param)
            base_url, query_params = utils.parse_query_url(url)
            expected_base_url = ('/stacks/teststack/abcd1234/'
                                 'resources/testresource/events')
            self.assertEqual(expected_base_url, base_url)
            expected_query_dict = {'marker': ['6d6935f4-0ae5'],
                                   'limit': ['2'],
                                   'resource_action': ['CREATE'],
                                   'resource_status': ['COMPLETE']}
            self.assertEqual(expected_query_dict, query_params)
            mock_re.assert_called_once_with(stack_id)
    def test_list_types_with_filters(self):
        filters = {'name': 'OS::Keystone::*',
                   'version': '5.0.0',
                   'support_status': 'SUPPORTED'}

        manager = resource_types.ResourceTypeManager(None)
        with mock.patch.object(manager, '_list') as mock_list:
            mock_list.return_value = None
            manager.list(filters=filters)
            self.assertEqual(1, mock_list.call_count)
            url, param = mock_list.call_args[0]
            self.assertEqual("resource_types", param)
            base_url, query_params = utils.parse_query_url(url)
            self.assertEqual('/%s' % manager.KEY, base_url)
            # parameters in query_params is in list format, so filter params
            # are made to be inline with it
            filters_params = {}
            for item in filters:
                filters_params[item] = [filters[item]]

            self.assertEqual(filters_params, query_params)
    def test_list_types_with_filters(self):
        filters = {
            'name': 'OS::Keystone::*',
            'version': '5.0.0',
            'support_status': 'SUPPORTED'
        }

        manager = resource_types.ResourceTypeManager(None)
        with mock.patch.object(manager, '_list') as mock_list:
            mock_list.return_value = None
            manager.list(filters=filters)
            self.assertEqual(1, mock_list.call_count)
            url, param = mock_list.call_args[0]
            self.assertEqual("resource_types", param)
            base_url, query_params = utils.parse_query_url(url)
            self.assertEqual('/%s' % manager.KEY, base_url)
            # parameters in query_params is in list format, so filter params
            # are made to be inline with it
            filters_params = {}
            for item in filters:
                filters_params[item] = [filters[item]]

            self.assertEqual(filters_params, query_params)