~corey.bryant/python-novaclient/2.26.0

« back to all changes in this revision

Viewing changes to novaclient/tests/fixture_data/client.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2014-09-18 08:52:31 UTC
  • mfrom: (1.1.35)
  • Revision ID: package-import@ubuntu.com-20140918085231-56hs515gp9zpb9sd
Tags: 1:2.19.0-0ubuntu1
* New upstream release.
* debian/control: Drop python-d2to1, python-httpretty as build dependency.
* debian/control: Add python-requests-mock as build dependency.
* debian/control: Add python-oslo.utils.

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
# under the License.
12
12
 
13
13
import fixtures
14
 
import httpretty
15
14
from keystoneclient.auth.identity import v2
 
15
from keystoneclient import fixture
16
16
from keystoneclient import session
17
17
 
18
 
from novaclient.openstack.common import jsonutils
19
18
from novaclient.v1_1 import client as v1_1client
20
19
from novaclient.v3 import client as v3client
21
20
 
25
24
 
26
25
class V1(fixtures.Fixture):
27
26
 
28
 
    def __init__(self, compute_url=COMPUTE_URL, identity_url=IDENTITY_URL):
 
27
    def __init__(self, requests,
 
28
                 compute_url=COMPUTE_URL, identity_url=IDENTITY_URL):
29
29
        super(V1, self).__init__()
30
30
        self.identity_url = identity_url
31
31
        self.compute_url = compute_url
32
32
        self.client = None
33
 
 
34
 
        self.token = {
35
 
            'access': {
36
 
                "token": {
37
 
                    "id": "ab48a9efdfedb23ty3494",
38
 
                    "expires": "2010-11-01T03:32:15-05:00",
39
 
                    "tenant": {
40
 
                        "id": "345",
41
 
                        "name": "My Project"
42
 
                    }
43
 
                },
44
 
                "user": {
45
 
                    "id": "123",
46
 
                    "name": "jqsmith",
47
 
                    "roles": [
48
 
                        {
49
 
                            "id": "234",
50
 
                            "name": "compute:admin",
51
 
                        },
52
 
                        {
53
 
                            "id": "235",
54
 
                            "name": "object-store:admin",
55
 
                            "tenantId": "1",
56
 
                        }
57
 
                    ],
58
 
                    "roles_links": [],
59
 
                },
60
 
                "serviceCatalog": [
61
 
                    {
62
 
                        "name": "Cloud Servers",
63
 
                        "type": "compute",
64
 
                        "endpoints": [
65
 
                            {
66
 
                                "publicURL": self.compute_url,
67
 
                                "internalURL": "https://compute1.host/v1/1",
68
 
                            },
69
 
                        ],
70
 
                        "endpoints_links": [],
71
 
                    },
72
 
                    {
73
 
                        "name": "Cloud Servers",
74
 
                        "type": "computev3",
75
 
                        "endpoints": [
76
 
                            {
77
 
                                "publicURL": self.compute_url,
78
 
                                "internalURL": "https://compute1.host/v1/1",
79
 
                            },
80
 
                        ],
81
 
                        "endpoints_links": [],
82
 
                    },
83
 
                ],
84
 
            }
85
 
        }
 
33
        self.requests = requests
 
34
 
 
35
        self.token = fixture.V2Token()
 
36
        self.token.set_scope()
 
37
 
 
38
        s = self.token.add_service('compute')
 
39
        s.add_endpoint(self.compute_url)
 
40
 
 
41
        s = self.token.add_service('computev3')
 
42
        s.add_endpoint(self.compute_url)
86
43
 
87
44
    def setUp(self):
88
45
        super(V1, self).setUp()
89
 
        httpretty.enable()
90
 
        self.addCleanup(httpretty.disable)
91
46
 
92
47
        auth_url = '%s/tokens' % self.identity_url
93
 
        httpretty.register_uri(httpretty.POST, auth_url,
94
 
                               body=jsonutils.dumps(self.token),
95
 
                               content_type='application/json')
 
48
        headers = {'X-Content-Type': 'application/json'}
 
49
        self.requests.register_uri('POST', auth_url,
 
50
                               json=self.token,
 
51
                               headers=headers)
96
52
        self.client = self.new_client()
97
53
 
98
54
    def new_client(self):