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

« back to all changes in this revision

Viewing changes to keystoneclient/tests/v3/test_discover.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 json
 
16
 
 
17
import httpretty
 
18
 
 
19
from keystoneclient.generic import client
 
20
from keystoneclient.tests.v3 import utils
 
21
 
 
22
 
 
23
class DiscoverKeystoneTests(utils.UnauthenticatedTestCase):
 
24
    def setUp(self):
 
25
        super(DiscoverKeystoneTests, self).setUp()
 
26
        self.TEST_RESPONSE_DICT = {
 
27
            "versions": {
 
28
                "values": [{"id": "v3.0",
 
29
                            "status": "beta",
 
30
                            "updated": "2013-03-06T00:00:00Z",
 
31
                            "links": [
 
32
                                {"rel": "self",
 
33
                                 "href": "http://127.0.0.1:5000/v3.0/", },
 
34
                                {"rel": "describedby",
 
35
                                 "type": "text/html",
 
36
                                 "href": "http://docs.openstack.org/api/"
 
37
                                         "openstack-identity-service/3/"
 
38
                                         "content/", },
 
39
                                {"rel": "describedby",
 
40
                                 "type": "application/pdf",
 
41
                                 "href": "http://docs.openstack.org/api/"
 
42
                                         "openstack-identity-service/3/"
 
43
                                         "identity-dev-guide-3.pdf", },
 
44
                            ]},
 
45
                           {"id": "v2.0",
 
46
                            "status": "beta",
 
47
                            "updated": "2013-03-06T00:00:00Z",
 
48
                            "links": [
 
49
                                {"rel": "self",
 
50
                                 "href": "http://127.0.0.1:5000/v2.0/", },
 
51
                                {"rel": "describedby",
 
52
                                 "type": "text/html",
 
53
                                 "href": "http://docs.openstack.org/api/"
 
54
                                         "openstack-identity-service/2.0/"
 
55
                                         "content/", },
 
56
                                {"rel": "describedby",
 
57
                                 "type": "application/pdf",
 
58
                                 "href": "http://docs.openstack.org/api/"
 
59
                                         "openstack-identity-service/2.0/"
 
60
                                         "identity-dev-guide-2.0.pdf", }
 
61
                            ]}],
 
62
            },
 
63
        }
 
64
        self.TEST_REQUEST_HEADERS = {
 
65
            'User-Agent': 'python-keystoneclient',
 
66
            'Accept': 'application/json',
 
67
        }
 
68
 
 
69
    @httpretty.activate
 
70
    def test_get_version_local(self):
 
71
        httpretty.register_uri(httpretty.GET, "http://localhost:35357/",
 
72
                               status=300,
 
73
                               body=json.dumps(self.TEST_RESPONSE_DICT))
 
74
 
 
75
        cs = client.Client()
 
76
        versions = cs.discover()
 
77
        self.assertIsInstance(versions, dict)
 
78
        self.assertIn('message', versions)
 
79
        self.assertIn('v3.0', versions)
 
80
        self.assertEqual(
 
81
            versions['v3.0']['url'],
 
82
            self.TEST_RESPONSE_DICT['versions']['values'][0]['links'][0]
 
83
            ['href'])
 
84
        self.assertEqual(
 
85
            versions['v2.0']['url'],
 
86
            self.TEST_RESPONSE_DICT['versions']['values'][1]['links'][0]
 
87
            ['href'])