1
# Copyright 2012 OpenStack LLC.
4
# Licensed under the Apache License, Version 2.0 (the "License"); you may
5
# not use this file except in compliance with the License. You may obtain
6
# a copy of the License at
8
# http://www.apache.org/licenses/LICENSE-2.0
10
# Unless required by applicable law or agreed to in writing, software
11
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
# License for the specific language governing permissions and limitations
16
import ceilometerclient.v2.resources
17
from tests import utils
27
'project_id': 'project_bla',
29
'metadata': {'zxc_id': 'bla'},
33
'project_id': 'dig_the_ditch',
35
'metadata': {'zxc_id': 'foo'},
40
'/v2/resources?q.op=&q.value=a&q.field=resource_id':
47
'project_id': 'project_bla',
49
'metadata': {'zxc_id': 'bla'},
60
'project_id': 'project_bla',
62
'metadata': {'zxc_id': 'bla'},
69
class ResourceManagerTest(utils.BaseTestCase):
72
super(ResourceManagerTest, self).setUp()
73
self.api = utils.FakeAPI(fixtures)
74
self.mgr = ceilometerclient.v2.resources.ResourceManager(self.api)
76
def test_list_all(self):
77
resources = list(self.mgr.list())
79
('GET', '/v2/resources', {}, None),
81
self.assertEqual(self.api.calls, expect)
82
self.assertEqual(len(resources), 2)
83
self.assertEqual(resources[0].resource_id, 'a')
84
self.assertEqual(resources[1].resource_id, 'b')
86
def test_list_one(self):
87
resource = self.mgr.get(resource_id='a')
89
('GET', '/v2/resources/a', {}, None),
91
self.assertEqual(self.api.calls, expect)
92
self.assertTrue(resource)
93
self.assertEqual(resource.resource_id, 'a')
95
def test_list_by_query(self):
96
resources = list(self.mgr.list(q=[{"field": "resource_id",
100
('GET', '/v2/resources?q.op=&q.value=a&q.field=resource_id',
103
self.assertEqual(self.api.calls, expect)
104
self.assertEqual(len(resources), 1)
105
self.assertEqual(resources[0].resource_id, 'a')