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

« back to all changes in this revision

Viewing changes to keystoneclient/tests/v3/test_endpoints.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
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
 
4
#    not use this file except in compliance with the License. You may obtain
 
5
#    a copy of the License at
 
6
#
 
7
#         http://www.apache.org/licenses/LICENSE-2.0
 
8
#
 
9
#    Unless required by applicable law or agreed to in writing, software
 
10
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 
11
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 
12
#    License for the specific language governing permissions and limitations
 
13
#    under the License.
 
14
 
 
15
import uuid
 
16
 
 
17
from keystoneclient import exceptions
 
18
from keystoneclient.tests.v3 import utils
 
19
from keystoneclient.v3 import endpoints
 
20
 
 
21
 
 
22
class EndpointTests(utils.TestCase, utils.CrudTests):
 
23
    def setUp(self):
 
24
        super(EndpointTests, self).setUp()
 
25
        self.key = 'endpoint'
 
26
        self.collection_key = 'endpoints'
 
27
        self.model = endpoints.Endpoint
 
28
        self.manager = self.client.endpoints
 
29
 
 
30
    def new_ref(self, **kwargs):
 
31
        kwargs = super(EndpointTests, self).new_ref(**kwargs)
 
32
        kwargs.setdefault('interface', 'public')
 
33
        kwargs.setdefault('region', uuid.uuid4().hex)
 
34
        kwargs.setdefault('service_id', uuid.uuid4().hex)
 
35
        kwargs.setdefault('url', uuid.uuid4().hex)
 
36
        kwargs.setdefault('enabled', True)
 
37
        return kwargs
 
38
 
 
39
    def test_create_public_interface(self):
 
40
        ref = self.new_ref(interface='public')
 
41
        self.test_create(ref)
 
42
 
 
43
    def test_create_admin_interface(self):
 
44
        ref = self.new_ref(interface='admin')
 
45
        self.test_create(ref)
 
46
 
 
47
    def test_create_internal_interface(self):
 
48
        ref = self.new_ref(interface='internal')
 
49
        self.test_create(ref)
 
50
 
 
51
    def test_create_invalid_interface(self):
 
52
        ref = self.new_ref(interface=uuid.uuid4().hex)
 
53
        self.assertRaises(exceptions.ValidationError, self.manager.create,
 
54
                          **utils.parameterize(ref))
 
55
 
 
56
    def test_update_public_interface(self):
 
57
        ref = self.new_ref(interface='public')
 
58
        self.test_update(ref)
 
59
 
 
60
    def test_update_admin_interface(self):
 
61
        ref = self.new_ref(interface='admin')
 
62
        self.test_update(ref)
 
63
 
 
64
    def test_update_internal_interface(self):
 
65
        ref = self.new_ref(interface='internal')
 
66
        self.test_update(ref)
 
67
 
 
68
    def test_update_invalid_interface(self):
 
69
        ref = self.new_ref(interface=uuid.uuid4().hex)
 
70
        ref['endpoint'] = "fake_endpoint"
 
71
        self.assertRaises(exceptions.ValidationError, self.manager.update,
 
72
                          **utils.parameterize(ref))
 
73
 
 
74
    def test_list_public_interface(self):
 
75
        interface = 'public'
 
76
        expected_path = 'v3/%s?interface=%s' % (self.collection_key, interface)
 
77
        self.test_list(expected_path=expected_path, interface=interface)
 
78
 
 
79
    def test_list_admin_interface(self):
 
80
        interface = 'admin'
 
81
        expected_path = 'v3/%s?interface=%s' % (self.collection_key, interface)
 
82
        self.test_list(expected_path=expected_path, interface=interface)
 
83
 
 
84
    def test_list_internal_interface(self):
 
85
        interface = 'admin'
 
86
        expected_path = 'v3/%s?interface=%s' % (self.collection_key, interface)
 
87
        self.test_list(expected_path=expected_path, interface=interface)
 
88
 
 
89
    def test_list_invalid_interface(self):
 
90
        interface = uuid.uuid4().hex
 
91
        expected_path = 'v3/%s?interface=%s' % (self.collection_key, interface)
 
92
        self.assertRaises(exceptions.ValidationError, self.manager.list,
 
93
                          expected_path=expected_path, interface=interface)