Revision 3c50df2e kamaki/clients/compute/test.py
b/kamaki/clients/compute/test.py | ||
---|---|---|
36 | 36 |
from itertools import product |
37 | 37 |
from json import dumps |
38 | 38 |
|
39 |
from kamaki.clients.compute import ComputeClient, ComputeRestClient |
|
40 |
from kamaki.clients import ClientError |
|
39 |
from kamaki.clients import ClientError, compute |
|
41 | 40 |
|
42 | 41 |
|
43 | 42 |
rest_pkg = 'kamaki.clients.compute.rest_api.ComputeRestClient' |
... | ... | |
111 | 110 |
pass |
112 | 111 |
|
113 | 112 |
|
114 |
class ComputeRest(TestCase): |
|
113 |
class ComputeRestClient(TestCase):
|
|
115 | 114 |
|
116 | 115 |
"""Set up a ComputesRest thorough test""" |
117 | 116 |
def setUp(self): |
118 | 117 |
self.url = 'http://cyclades.example.com' |
119 | 118 |
self.token = 'cyc14d3s70k3n' |
120 |
self.client = ComputeRestClient(self.url, self.token) |
|
119 |
self.client = compute.ComputeRestClient(self.url, self.token)
|
|
121 | 120 |
|
122 | 121 |
def tearDown(self): |
123 | 122 |
FR.json = vm_recv |
... | ... | |
232 | 231 |
self._test_put('images') |
233 | 232 |
|
234 | 233 |
|
235 |
class Compute(TestCase): |
|
234 |
class ComputeClient(TestCase):
|
|
236 | 235 |
|
237 | 236 |
def assert_dicts_are_equal(self, d1, d2): |
238 | 237 |
for k, v in d1.items(): |
... | ... | |
246 | 245 |
def setUp(self): |
247 | 246 |
self.url = 'http://cyclades.example.com' |
248 | 247 |
self.token = 'cyc14d3s70k3n' |
249 |
self.client = ComputeClient(self.url, self.token) |
|
248 |
self.client = compute.ComputeClient(self.url, self.token)
|
|
250 | 249 |
|
251 | 250 |
def tearDown(self): |
252 | 251 |
FR.status_code = 200 |
... | ... | |
257 | 256 |
return_value=img_recv['image']) |
258 | 257 |
def test_create_server(self, GID): |
259 | 258 |
with patch.object( |
260 |
ComputeClient, 'servers_post', |
|
259 |
compute.ComputeClient, 'servers_post',
|
|
261 | 260 |
side_effect=ClientError( |
262 | 261 |
'REQUEST ENTITY TOO LARGE', |
263 | 262 |
status=403)): |
... | ... | |
267 | 266 |
vm_name, fid, img_ref) |
268 | 267 |
|
269 | 268 |
with patch.object( |
270 |
ComputeClient, 'servers_post', |
|
269 |
compute.ComputeClient, 'servers_post',
|
|
271 | 270 |
return_value=FR()) as post: |
272 | 271 |
r = self.client.create_server(vm_name, fid, img_ref) |
273 | 272 |
self.assertEqual(r, FR.json['server']) |
... | ... | |
444 | 443 |
from sys import argv |
445 | 444 |
from kamaki.clients.test import runTestCase |
446 | 445 |
not_found = True |
447 |
if not argv[1:] or argv[1] == 'Compute': |
|
446 |
if not argv[1:] or argv[1] == 'ComputeClient':
|
|
448 | 447 |
not_found = False |
449 |
runTestCase(Compute, 'Compute Client', argv[2:]) |
|
448 |
runTestCase(ComputeClient, 'Compute Client', argv[2:])
|
|
450 | 449 |
if not argv[1:] or argv[1] == 'ComputeRest': |
451 | 450 |
not_found = False |
452 |
runTestCase(ComputeRest, 'ComputeRest Client', argv[2:]) |
|
451 |
runTestCase(ComputeRestClient, 'ComputeRest Client', argv[2:])
|
|
453 | 452 |
if not_found: |
454 | 453 |
print('TestCase %s not found' % argv[1]) |
Also available in: Unified diff