~ubuntu-branches/ubuntu/trusty/python-ceilometerclient/trusty

« back to all changes in this revision

Viewing changes to ceilometerclient/tests/v1/test_users.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2013-08-13 11:27:54 UTC
  • mfrom: (1.1.3)
  • Revision ID: package-import@ubuntu.com-20130813112754-fz58btmvrw9gsrhn
Tags: 1.0.3-0ubuntu1
* New upstream release. 
* debian/patches/fix-keystoneclient-version.patch: Dropped no longer needed. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright 2012 OpenStack LLC.
 
2
# All Rights Reserved.
 
3
#
 
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
 
7
#
 
8
#         http://www.apache.org/licenses/LICENSE-2.0
 
9
#
 
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
 
14
#    under the License.
 
15
 
 
16
from ceilometerclient.tests import utils
 
17
import ceilometerclient.v1.meters
 
18
 
 
19
 
 
20
fixtures = {
 
21
    '/v1/users': {
 
22
        'GET': (
 
23
            {},
 
24
            {'users': [
 
25
                'a',
 
26
                'b',
 
27
            ]},
 
28
        ),
 
29
    },
 
30
    '/v1/sources/source_b/users': {
 
31
        'GET': (
 
32
            {},
 
33
            {'users': ['b']},
 
34
        ),
 
35
    },
 
36
}
 
37
 
 
38
 
 
39
class UserManagerTest(utils.BaseTestCase):
 
40
 
 
41
    def setUp(self):
 
42
        super(UserManagerTest, self).setUp()
 
43
        self.api = utils.FakeAPI(fixtures)
 
44
        self.mgr = ceilometerclient.v1.meters.UserManager(self.api)
 
45
 
 
46
    def test_list_all(self):
 
47
        users = list(self.mgr.list())
 
48
        expect = [
 
49
            ('GET', '/v1/users', {}, None),
 
50
        ]
 
51
        self.assertEqual(self.api.calls, expect)
 
52
        self.assertEqual(len(users), 2)
 
53
        self.assertEqual(users[0].user_id, 'a')
 
54
        self.assertEqual(users[1].user_id, 'b')
 
55
 
 
56
    def test_list_by_source(self):
 
57
        users = list(self.mgr.list(source='source_b'))
 
58
        expect = [
 
59
            ('GET', '/v1/sources/source_b/users', {}, None),
 
60
        ]
 
61
        self.assertEqual(self.api.calls, expect)
 
62
        self.assertEqual(len(users), 1)
 
63
        self.assertEqual(users[0].user_id, 'b')