~ubuntu-branches/ubuntu/trusty/python-keystoneclient/trusty-proposed

« back to all changes in this revision

Viewing changes to tests/v3/test_groups.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short, Adam Gandelman, Chuck Short
  • Date: 2013-11-14 10:51:32 UTC
  • mfrom: (1.1.23)
  • Revision ID: package-import@ubuntu.com-20131114105132-p1o428l7fclasv9e
Tags: 1:0.4.1-0ubuntu1
[ Adam Gandelman ]
* debian/patches: Refreshed.
* debian/patches/use-mox-dependency.patch: Use mox instead of mox3
  dependency.

[ Chuck Short ]
* New upstream release.
* debian/control:
  - open icehouse release.
  - Dropped python-d2to1 and python-httplib2 dependency.
* debian/patches/skip-tests-ubuntu.patch: Dropped no longer needed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# vim: tabstop=4 shiftwidth=4 softtabstop=4
2
 
 
3
 
# Copyright 2012 OpenStack LLC
4
 
#
5
 
# Licensed under the Apache License, Version 2.0 (the "License"); you may
6
 
# not use this file except in compliance with the License. You may obtain
7
 
# a copy of the License at
8
 
#
9
 
#      http://www.apache.org/licenses/LICENSE-2.0
10
 
#
11
 
# Unless required by applicable law or agreed to in writing, software
12
 
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
 
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
 
# License for the specific language governing permissions and limitations
15
 
# under the License.
16
 
 
17
 
import copy
18
 
import urlparse
19
 
import uuid
20
 
 
21
 
import requests
22
 
 
23
 
from keystoneclient.v3 import groups
24
 
from tests.v3 import utils
25
 
 
26
 
 
27
 
class GroupTests(utils.TestCase, utils.CrudTests):
28
 
    def setUp(self):
29
 
        super(GroupTests, self).setUp()
30
 
        self.additionalSetUp()
31
 
        self.key = 'group'
32
 
        self.collection_key = 'groups'
33
 
        self.model = groups.Group
34
 
        self.manager = self.client.groups
35
 
 
36
 
    def new_ref(self, **kwargs):
37
 
        kwargs = super(GroupTests, self).new_ref(**kwargs)
38
 
        kwargs.setdefault('name', uuid.uuid4().hex)
39
 
        return kwargs
40
 
 
41
 
    def test_list_groups_for_user(self):
42
 
        user_id = uuid.uuid4().hex
43
 
        ref_list = [self.new_ref(), self.new_ref()]
44
 
        resp = utils.TestResponse({
45
 
            "status_code": 200,
46
 
            "text": self.serialize(ref_list),
47
 
        })
48
 
 
49
 
        method = 'GET'
50
 
        kwargs = copy.copy(self.TEST_REQUEST_BASE)
51
 
        kwargs['headers'] = self.headers[method]
52
 
        requests.request(
53
 
            method,
54
 
            urlparse.urljoin(
55
 
                self.TEST_URL,
56
 
                'v3/users/%s/%s' % (
57
 
                    user_id, self.collection_key)),
58
 
            **kwargs).AndReturn((resp))
59
 
        self.mox.ReplayAll()
60
 
 
61
 
        returned_list = self.manager.list(user=user_id)
62
 
        self.assertTrue(len(returned_list))
63
 
        [self.assertTrue(isinstance(r, self.model)) for r in returned_list]
64
 
 
65
 
    def test_list_groups_for_domain(self):
66
 
        ref_list = [self.new_ref(), self.new_ref()]
67
 
 
68
 
        domain_id = uuid.uuid4().hex
69
 
        resp = utils.TestResponse({
70
 
            "status_code": 200,
71
 
            "text": self.serialize(ref_list),
72
 
        })
73
 
 
74
 
        method = 'GET'
75
 
        kwargs = copy.copy(self.TEST_REQUEST_BASE)
76
 
        kwargs['headers'] = self.headers[method]
77
 
        requests.request(
78
 
            method,
79
 
            urlparse.urljoin(
80
 
                self.TEST_URL,
81
 
                'v3/%s?domain_id=%s' % (self.collection_key, domain_id)),
82
 
            **kwargs).AndReturn((resp))
83
 
        self.mox.ReplayAll()
84
 
 
85
 
        returned_list = self.manager.list(domain=domain_id)
86
 
        self.assertTrue(len(returned_list))
87
 
        [self.assertTrue(isinstance(r, self.model)) for r in returned_list]