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
18
import ceilometerclient.v2.statistics
19
from tests import utils
23
'/v2/meters/instance/statistics':
29
u'duration_start': u'2013-02-04T10:51:42',
33
u'2013-02-05T15:46:09',
40
'/v2/meters/instance/statistics?q.op=&q.op=&q.value=foo&q.value=bar&q.field=resource_id&q.field=source':
46
u'duration_start': u'2013-02-04T10:51:42',
50
u'2013-02-05T15:46:09',
60
class StatisticsManagerTest(unittest.TestCase):
63
self.api = utils.FakeAPI(fixtures)
64
self.mgr = ceilometerclient.v2.statistics.StatisticsManager(self.api)
66
def test_list_by_meter_name(self):
67
stats = list(self.mgr.list(meter_name='instance'))
69
('GET', '/v2/meters/instance/statistics', {}, None),
71
self.assertEqual(self.api.calls, expect)
72
self.assertEqual(len(stats), 1)
73
self.assertEqual(stats[0].count, 135)
75
def test_list_by_meter_name_extended(self):
76
stats = list(self.mgr.list(meter_name='instance',
78
{"field": "resource_id",
85
'/v2/meters/instance/statistics?q.op=&q.op=&q.value=foo&q.value=bar&q.field=resource_id&q.field=source',
88
self.assertEqual(self.api.calls, expect)
89
self.assertEqual(len(stats), 1)
90
self.assertEqual(stats[0].count, 135)