root / kamaki / clients / cyclades / test.py @ c6ebe715
History | View | Annotate | Download (21.3 kB)
1 | 24851aa5 | Stavros Sachtouris | # Copyright 2013 GRNET S.A. All rights reserved.
|
---|---|---|---|
2 | c1004a00 | Stavros Sachtouris | #
|
3 | c1004a00 | Stavros Sachtouris | # Redistribution and use in source and binary forms, with or
|
4 | c1004a00 | Stavros Sachtouris | # without modification, are permitted provided that the following
|
5 | c1004a00 | Stavros Sachtouris | # conditions are met:
|
6 | c1004a00 | Stavros Sachtouris | #
|
7 | c1004a00 | Stavros Sachtouris | # 1. Redistributions of source code must retain the above
|
8 | c1004a00 | Stavros Sachtouris | # copyright notice, this list of conditions and the following
|
9 | c1004a00 | Stavros Sachtouris | # disclaimer.
|
10 | c1004a00 | Stavros Sachtouris | #
|
11 | c1004a00 | Stavros Sachtouris | # 2. Redistributions in binary form must reproduce the above
|
12 | c1004a00 | Stavros Sachtouris | # copyright notice, this list of conditions and the following
|
13 | c1004a00 | Stavros Sachtouris | # disclaimer in the documentation and/or other materials
|
14 | c1004a00 | Stavros Sachtouris | # provided with the distribution.
|
15 | c1004a00 | Stavros Sachtouris | #
|
16 | c1004a00 | Stavros Sachtouris | # THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
|
17 | c1004a00 | Stavros Sachtouris | # OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
18 | c1004a00 | Stavros Sachtouris | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
19 | c1004a00 | Stavros Sachtouris | # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
|
20 | c1004a00 | Stavros Sachtouris | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
21 | c1004a00 | Stavros Sachtouris | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
22 | c1004a00 | Stavros Sachtouris | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
23 | c1004a00 | Stavros Sachtouris | # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
24 | c1004a00 | Stavros Sachtouris | # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
25 | c1004a00 | Stavros Sachtouris | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
26 | c1004a00 | Stavros Sachtouris | # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
27 | c1004a00 | Stavros Sachtouris | # POSSIBILITY OF SUCH DAMAGE.
|
28 | c1004a00 | Stavros Sachtouris | #
|
29 | c1004a00 | Stavros Sachtouris | # The views and conclusions contained in the software and
|
30 | c1004a00 | Stavros Sachtouris | # documentation are those of the authors and should not be
|
31 | c1004a00 | Stavros Sachtouris | # interpreted as representing official policies, either expressed
|
32 | c1004a00 | Stavros Sachtouris | # or implied, of GRNET S.A.
|
33 | 3c50df2e | Stavros Sachtouris | |
34 | 0482817c | Stavros Sachtouris | from mock import patch, call |
35 | 03493855 | Stavros Sachtouris | from unittest import TestCase |
36 | 68fd1bda | Stavros Sachtouris | from itertools import product |
37 | 77d1b504 | Stavros Sachtouris | from json import dumps |
38 | 03493855 | Stavros Sachtouris | |
39 | 3c50df2e | Stavros Sachtouris | from kamaki.clients import ClientError, cyclades |
40 | 03493855 | Stavros Sachtouris | |
41 | 03493855 | Stavros Sachtouris | img_ref = "1m4g3-r3f3r3nc3"
|
42 | 03493855 | Stavros Sachtouris | vm_name = "my new VM"
|
43 | 03493855 | Stavros Sachtouris | fid = 42
|
44 | 03493855 | Stavros Sachtouris | vm_recv = dict(server=dict( |
45 | 03493855 | Stavros Sachtouris | status="BUILD",
|
46 | 03493855 | Stavros Sachtouris | updated="2013-03-01T10:04:00.637152+00:00",
|
47 | 03493855 | Stavros Sachtouris | hostId="",
|
48 | 5e194c99 | Stavros Sachtouris | name=vm_name, |
49 | 5e194c99 | Stavros Sachtouris | imageRef=img_ref, |
50 | 03493855 | Stavros Sachtouris | created="2013-03-01T10:04:00.087324+00:00",
|
51 | 03493855 | Stavros Sachtouris | flavorRef=fid, |
52 | 03493855 | Stavros Sachtouris | adminPass="n0n3sh@11p@55",
|
53 | 03493855 | Stavros Sachtouris | suspended=False,
|
54 | 03493855 | Stavros Sachtouris | progress=0,
|
55 | 03493855 | Stavros Sachtouris | id=31173,
|
56 | bcef3ac9 | Stavros Sachtouris | metadata=dict(os="debian", users="root"))) |
57 | bcef3ac9 | Stavros Sachtouris | vm_list = dict(servers=[
|
58 | 257b931a | Stavros Sachtouris | dict(name='n1', id=1), |
59 | bcef3ac9 | Stavros Sachtouris | dict(name='n2', id=2)]) |
60 | e6ec9ea6 | Stavros Sachtouris | net_send = dict(network=dict(dhcp=False, name='someNet')) |
61 | e6ec9ea6 | Stavros Sachtouris | net_recv = dict(network=dict( |
62 | e6ec9ea6 | Stavros Sachtouris | status="PENDING",
|
63 | e6ec9ea6 | Stavros Sachtouris | updated="2013-03-05T15:04:51.758780+00:00",
|
64 | e6ec9ea6 | Stavros Sachtouris | name="someNet",
|
65 | e6ec9ea6 | Stavros Sachtouris | created="2013-03-05T15:04:51.758728+00:00",
|
66 | e6ec9ea6 | Stavros Sachtouris | cidr6=None,
|
67 | e6ec9ea6 | Stavros Sachtouris | id="2130",
|
68 | e6ec9ea6 | Stavros Sachtouris | gateway6=None,
|
69 | e6ec9ea6 | Stavros Sachtouris | public=False,
|
70 | e6ec9ea6 | Stavros Sachtouris | dhcp=False,
|
71 | e6ec9ea6 | Stavros Sachtouris | cidr="192.168.1.0/24",
|
72 | e6ec9ea6 | Stavros Sachtouris | type="MAC_FILTERED",
|
73 | e6ec9ea6 | Stavros Sachtouris | gateway=None,
|
74 | bcef3ac9 | Stavros Sachtouris | attachments=[dict(name='att1'), dict(name='att2')])) |
75 | bcef3ac9 | Stavros Sachtouris | net_list = dict(networks=[
|
76 | 0da4f84b | Stavros Sachtouris | dict(id=1, name='n1'), |
77 | 0da4f84b | Stavros Sachtouris | dict(id=2, name='n2'), |
78 | bcef3ac9 | Stavros Sachtouris | dict(id=3, name='n3')]) |
79 | bcef3ac9 | Stavros Sachtouris | firewalls = dict(attachments=[
|
80 | bcef3ac9 | Stavros Sachtouris | dict(firewallProfile='50m3_pr0f1L3', otherStuff='57uff')]) |
81 | 03493855 | Stavros Sachtouris | |
82 | 03493855 | Stavros Sachtouris | |
83 | 975270f2 | Stavros Sachtouris | class FR(object): |
84 | 975270f2 | Stavros Sachtouris | """FR stands for Fake Response"""
|
85 | 975270f2 | Stavros Sachtouris | json = vm_recv |
86 | 975270f2 | Stavros Sachtouris | headers = {} |
87 | 975270f2 | Stavros Sachtouris | content = json |
88 | 975270f2 | Stavros Sachtouris | status = None
|
89 | 975270f2 | Stavros Sachtouris | status_code = 200
|
90 | 975270f2 | Stavros Sachtouris | |
91 | 55faa0bc | Stavros Sachtouris | rest_pkg = 'kamaki.clients.cyclades.CycladesRestClient'
|
92 | 975270f2 | Stavros Sachtouris | cyclades_pkg = 'kamaki.clients.cyclades.CycladesClient'
|
93 | 975270f2 | Stavros Sachtouris | |
94 | 975270f2 | Stavros Sachtouris | |
95 | 3c50df2e | Stavros Sachtouris | class CycladesRestClient(TestCase): |
96 | 68fd1bda | Stavros Sachtouris | |
97 | 68fd1bda | Stavros Sachtouris | """Set up a Cyclades thorough test"""
|
98 | 68fd1bda | Stavros Sachtouris | def setUp(self): |
99 | 68fd1bda | Stavros Sachtouris | self.url = 'http://cyclades.example.com' |
100 | 68fd1bda | Stavros Sachtouris | self.token = 'cyc14d3s70k3n' |
101 | 3c50df2e | Stavros Sachtouris | self.client = cyclades.CycladesRestClient(self.url, self.token) |
102 | 68fd1bda | Stavros Sachtouris | |
103 | 68fd1bda | Stavros Sachtouris | def tearDown(self): |
104 | 68fd1bda | Stavros Sachtouris | FR.json = vm_recv |
105 | 68fd1bda | Stavros Sachtouris | |
106 | fc835c42 | Stavros Sachtouris | @patch('%s.get' % rest_pkg, return_value=FR()) |
107 | fc835c42 | Stavros Sachtouris | def test_networks_get(self, get): |
108 | fc835c42 | Stavros Sachtouris | for args in product( |
109 | fc835c42 | Stavros Sachtouris | ('', 'net_id'), |
110 | fc835c42 | Stavros Sachtouris | ('', 'cmd'), |
111 | fc835c42 | Stavros Sachtouris | (200, 204), |
112 | fc835c42 | Stavros Sachtouris | ({}, {'k': 'v'})): |
113 | fc835c42 | Stavros Sachtouris | (srv_id, command, success, kwargs) = args |
114 | fc835c42 | Stavros Sachtouris | self.client.networks_get(*args[:3], **kwargs) |
115 | fc835c42 | Stavros Sachtouris | srv_str = '/%s' % srv_id if srv_id else '' |
116 | fc835c42 | Stavros Sachtouris | cmd_str = '/%s' % command if command else '' |
117 | fc835c42 | Stavros Sachtouris | self.assertEqual(get.mock_calls[-1], call( |
118 | fc835c42 | Stavros Sachtouris | '/networks%s%s' % (srv_str, cmd_str),
|
119 | fc835c42 | Stavros Sachtouris | success=success, |
120 | fc835c42 | Stavros Sachtouris | **kwargs)) |
121 | fc835c42 | Stavros Sachtouris | |
122 | fc835c42 | Stavros Sachtouris | @patch('%s.delete' % rest_pkg, return_value=FR()) |
123 | fc835c42 | Stavros Sachtouris | def test_networks_delete(self, delete): |
124 | fc835c42 | Stavros Sachtouris | for args in product( |
125 | fc835c42 | Stavros Sachtouris | ('', 'net_id'), |
126 | fc835c42 | Stavros Sachtouris | ('', 'cmd'), |
127 | fc835c42 | Stavros Sachtouris | (202, 204), |
128 | fc835c42 | Stavros Sachtouris | ({}, {'k': 'v'})): |
129 | fc835c42 | Stavros Sachtouris | (srv_id, command, success, kwargs) = args |
130 | fc835c42 | Stavros Sachtouris | self.client.networks_delete(*args[:3], **kwargs) |
131 | fc835c42 | Stavros Sachtouris | srv_str = '/%s' % srv_id if srv_id else '' |
132 | fc835c42 | Stavros Sachtouris | cmd_str = '/%s' % command if command else '' |
133 | fc835c42 | Stavros Sachtouris | self.assertEqual(delete.mock_calls[-1], call( |
134 | fc835c42 | Stavros Sachtouris | '/networks%s%s' % (srv_str, cmd_str),
|
135 | fc835c42 | Stavros Sachtouris | success=success, |
136 | fc835c42 | Stavros Sachtouris | **kwargs)) |
137 | 68fd1bda | Stavros Sachtouris | |
138 | 50edcde7 | Stavros Sachtouris | @patch('%s.set_header' % rest_pkg) |
139 | 50edcde7 | Stavros Sachtouris | @patch('%s.post' % rest_pkg, return_value=FR()) |
140 | 50edcde7 | Stavros Sachtouris | def test_networks_post(self, post, SH): |
141 | 50edcde7 | Stavros Sachtouris | for args in product( |
142 | 50edcde7 | Stavros Sachtouris | ('', 'net_id'), |
143 | 50edcde7 | Stavros Sachtouris | ('', 'cmd'), |
144 | 50edcde7 | Stavros Sachtouris | (None, [dict(json="data"), dict(data="json")]), |
145 | 50edcde7 | Stavros Sachtouris | (202, 204), |
146 | 50edcde7 | Stavros Sachtouris | ({}, {'k': 'v'})): |
147 | 50edcde7 | Stavros Sachtouris | (srv_id, command, json_data, success, kwargs) = args |
148 | 50edcde7 | Stavros Sachtouris | self.client.networks_post(*args[:4], **kwargs) |
149 | 50edcde7 | Stavros Sachtouris | vm_str = '/%s' % srv_id if srv_id else '' |
150 | 50edcde7 | Stavros Sachtouris | cmd_str = '/%s' % command if command else '' |
151 | 50edcde7 | Stavros Sachtouris | if json_data:
|
152 | 50edcde7 | Stavros Sachtouris | json_data = dumps(json_data) |
153 | 50edcde7 | Stavros Sachtouris | self.assertEqual(SH.mock_calls[-2:], [ |
154 | 50edcde7 | Stavros Sachtouris | call('Content-Type', 'application/json'), |
155 | 50edcde7 | Stavros Sachtouris | call('Content-Length', len(json_data))]) |
156 | 50edcde7 | Stavros Sachtouris | self.assertEqual(post.mock_calls[-1], call( |
157 | 50edcde7 | Stavros Sachtouris | '/networks%s%s' % (vm_str, cmd_str),
|
158 | 50edcde7 | Stavros Sachtouris | data=json_data, success=success, |
159 | 50edcde7 | Stavros Sachtouris | **kwargs)) |
160 | 50edcde7 | Stavros Sachtouris | |
161 | cd5c8cc9 | Stavros Sachtouris | @patch('%s.set_header' % rest_pkg) |
162 | cd5c8cc9 | Stavros Sachtouris | @patch('%s.put' % rest_pkg, return_value=FR()) |
163 | cd5c8cc9 | Stavros Sachtouris | def test_networks_put(self, put, SH): |
164 | cd5c8cc9 | Stavros Sachtouris | for args in product( |
165 | cd5c8cc9 | Stavros Sachtouris | ('', 'net_id'), |
166 | cd5c8cc9 | Stavros Sachtouris | ('', 'cmd'), |
167 | cd5c8cc9 | Stavros Sachtouris | (None, [dict(json="data"), dict(data="json")]), |
168 | cd5c8cc9 | Stavros Sachtouris | (202, 204), |
169 | cd5c8cc9 | Stavros Sachtouris | ({}, {'k': 'v'})): |
170 | cd5c8cc9 | Stavros Sachtouris | (srv_id, command, json_data, success, kwargs) = args |
171 | cd5c8cc9 | Stavros Sachtouris | self.client.networks_put(*args[:4], **kwargs) |
172 | cd5c8cc9 | Stavros Sachtouris | vm_str = '/%s' % srv_id if srv_id else '' |
173 | cd5c8cc9 | Stavros Sachtouris | cmd_str = '/%s' % command if command else '' |
174 | cd5c8cc9 | Stavros Sachtouris | if json_data:
|
175 | cd5c8cc9 | Stavros Sachtouris | json_data = dumps(json_data) |
176 | cd5c8cc9 | Stavros Sachtouris | self.assertEqual(SH.mock_calls[-2:], [ |
177 | cd5c8cc9 | Stavros Sachtouris | call('Content-Type', 'application/json'), |
178 | cd5c8cc9 | Stavros Sachtouris | call('Content-Length', len(json_data))]) |
179 | cd5c8cc9 | Stavros Sachtouris | self.assertEqual(put.mock_calls[-1], call( |
180 | cd5c8cc9 | Stavros Sachtouris | '/networks%s%s' % (vm_str, cmd_str),
|
181 | cd5c8cc9 | Stavros Sachtouris | data=json_data, success=success, |
182 | cd5c8cc9 | Stavros Sachtouris | **kwargs)) |
183 | cd5c8cc9 | Stavros Sachtouris | |
184 | 0a62912d | Stavros Sachtouris | @patch('%s.get' % rest_pkg, return_value=FR()) |
185 | 0a62912d | Stavros Sachtouris | def test_floating_ip_pools_get(self, get): |
186 | 0a62912d | Stavros Sachtouris | for args in product( |
187 | 0a62912d | Stavros Sachtouris | (200, 204), |
188 | 0a62912d | Stavros Sachtouris | ({}, {'k': 'v'})): |
189 | 0a62912d | Stavros Sachtouris | success, kwargs = args |
190 | 0a62912d | Stavros Sachtouris | r = self.client.floating_ip_pools_get(success, **kwargs)
|
191 | 0a62912d | Stavros Sachtouris | self.assertTrue(isinstance(r, FR)) |
192 | 0a62912d | Stavros Sachtouris | self.assertEqual(get.mock_calls[-1], call( |
193 | 0a62912d | Stavros Sachtouris | '/os-floating-ip-pools', success=success, **kwargs))
|
194 | 0a62912d | Stavros Sachtouris | |
195 | 77d1b504 | Stavros Sachtouris | @patch('%s.get' % rest_pkg, return_value=FR()) |
196 | 77d1b504 | Stavros Sachtouris | def test_floating_ips_get(self, get): |
197 | 77d1b504 | Stavros Sachtouris | for args in product( |
198 | 03033b54 | Stavros Sachtouris | ('fip', ''), |
199 | 77d1b504 | Stavros Sachtouris | (200, 204), |
200 | 77d1b504 | Stavros Sachtouris | ({}, {'k': 'v'})): |
201 | 03033b54 | Stavros Sachtouris | fip, success, kwargs = args |
202 | 03033b54 | Stavros Sachtouris | r = self.client.floating_ips_get(fip, success, **kwargs)
|
203 | 77d1b504 | Stavros Sachtouris | self.assertTrue(isinstance(r, FR)) |
204 | 03033b54 | Stavros Sachtouris | expected = '' if not fip else '/%s' % fip |
205 | 77d1b504 | Stavros Sachtouris | self.assertEqual(get.mock_calls[-1], call( |
206 | 03033b54 | Stavros Sachtouris | '/os-floating-ips%s' % expected, success=success, **kwargs))
|
207 | 77d1b504 | Stavros Sachtouris | |
208 | 77d1b504 | Stavros Sachtouris | @patch('%s.set_header' % rest_pkg) |
209 | 77d1b504 | Stavros Sachtouris | @patch('%s.post' % rest_pkg, return_value=FR()) |
210 | 77d1b504 | Stavros Sachtouris | def test_floating_ips_post(self, post, SH): |
211 | 77d1b504 | Stavros Sachtouris | for args in product( |
212 | 77d1b504 | Stavros Sachtouris | (None, [dict(json="data"), dict(data="json")]), |
213 | 03033b54 | Stavros Sachtouris | ('fip', ''), |
214 | 77d1b504 | Stavros Sachtouris | (202, 204), |
215 | 77d1b504 | Stavros Sachtouris | ({}, {'k': 'v'})): |
216 | 03033b54 | Stavros Sachtouris | json_data, fip, success, kwargs = args |
217 | 03033b54 | Stavros Sachtouris | self.client.floating_ips_post(*args[:3], **kwargs) |
218 | 77d1b504 | Stavros Sachtouris | if json_data:
|
219 | 77d1b504 | Stavros Sachtouris | json_data = dumps(json_data) |
220 | 77d1b504 | Stavros Sachtouris | self.assertEqual(SH.mock_calls[-2:], [ |
221 | 77d1b504 | Stavros Sachtouris | call('Content-Type', 'application/json'), |
222 | 77d1b504 | Stavros Sachtouris | call('Content-Length', len(json_data))]) |
223 | 03033b54 | Stavros Sachtouris | expected = '' if not fip else '/%s' % fip |
224 | 77d1b504 | Stavros Sachtouris | self.assertEqual(post.mock_calls[-1], call( |
225 | 03033b54 | Stavros Sachtouris | '/os-floating-ips%s' % expected,
|
226 | 77d1b504 | Stavros Sachtouris | data=json_data, success=success, |
227 | 77d1b504 | Stavros Sachtouris | **kwargs)) |
228 | 77d1b504 | Stavros Sachtouris | |
229 | 77d1b504 | Stavros Sachtouris | @patch('%s.delete' % rest_pkg, return_value=FR()) |
230 | 03033b54 | Stavros Sachtouris | def test_floating_ips_delete(self, delete): |
231 | 77d1b504 | Stavros Sachtouris | for args in product( |
232 | 77d1b504 | Stavros Sachtouris | ('fip1', 'fip2'), |
233 | 77d1b504 | Stavros Sachtouris | (200, 204), |
234 | 77d1b504 | Stavros Sachtouris | ({}, {'k': 'v'})): |
235 | 77d1b504 | Stavros Sachtouris | fip, success, kwargs = args |
236 | 03033b54 | Stavros Sachtouris | r = self.client.floating_ips_delete(fip, success, **kwargs)
|
237 | 77d1b504 | Stavros Sachtouris | self.assertTrue(isinstance(r, FR)) |
238 | 77d1b504 | Stavros Sachtouris | self.assertEqual(delete.mock_calls[-1], call( |
239 | 03033b54 | Stavros Sachtouris | '/os-floating-ips/%s' % fip, success=success, **kwargs))
|
240 | 77d1b504 | Stavros Sachtouris | |
241 | 68fd1bda | Stavros Sachtouris | |
242 | 3c50df2e | Stavros Sachtouris | class CycladesClient(TestCase): |
243 | 03493855 | Stavros Sachtouris | |
244 | 257b931a | Stavros Sachtouris | def assert_dicts_are_equal(self, d1, d2): |
245 | 03493855 | Stavros Sachtouris | for k, v in d1.items(): |
246 | 03493855 | Stavros Sachtouris | self.assertTrue(k in d2) |
247 | 03493855 | Stavros Sachtouris | if isinstance(v, dict): |
248 | 257b931a | Stavros Sachtouris | self.assert_dicts_are_equal(v, d2[k])
|
249 | 03493855 | Stavros Sachtouris | else:
|
250 | 03493855 | Stavros Sachtouris | self.assertEqual(unicode(v), unicode(d2[k])) |
251 | 03493855 | Stavros Sachtouris | |
252 | c1004a00 | Stavros Sachtouris | """Set up a Cyclades thorough test"""
|
253 | c1004a00 | Stavros Sachtouris | def setUp(self): |
254 | 03493855 | Stavros Sachtouris | self.url = 'http://cyclades.example.com' |
255 | 03493855 | Stavros Sachtouris | self.token = 'cyc14d3s70k3n' |
256 | 3c50df2e | Stavros Sachtouris | self.client = cyclades.CycladesClient(self.url, self.token) |
257 | c1004a00 | Stavros Sachtouris | |
258 | c1004a00 | Stavros Sachtouris | def tearDown(self): |
259 | 975270f2 | Stavros Sachtouris | FR.status_code = 200
|
260 | 975270f2 | Stavros Sachtouris | FR.json = vm_recv |
261 | c1004a00 | Stavros Sachtouris | |
262 | 6290b789 | Stavros Sachtouris | @patch('%s.servers_action_post' % cyclades_pkg, return_value=FR()) |
263 | d841b964 | Stavros Sachtouris | def test_shutdown_server(self, SP): |
264 | 386d82a1 | Stavros Sachtouris | vm_id = vm_recv['server']['id'] |
265 | 975270f2 | Stavros Sachtouris | self.client.shutdown_server(vm_id)
|
266 | fb392083 | Stavros Sachtouris | SP.assert_called_once_with( |
267 | 6290b789 | Stavros Sachtouris | vm_id, json_data=dict(shutdown=dict()), success=202) |
268 | 975270f2 | Stavros Sachtouris | |
269 | 6290b789 | Stavros Sachtouris | @patch('%s.servers_action_post' % cyclades_pkg, return_value=FR()) |
270 | cecad288 | Stavros Sachtouris | def test_start_server(self, SP): |
271 | 2c987e80 | Stavros Sachtouris | vm_id = vm_recv['server']['id'] |
272 | 975270f2 | Stavros Sachtouris | self.client.start_server(vm_id)
|
273 | fb392083 | Stavros Sachtouris | SP.assert_called_once_with( |
274 | 6290b789 | Stavros Sachtouris | vm_id, json_data=dict(start=dict()), success=202) |
275 | 975270f2 | Stavros Sachtouris | |
276 | 6290b789 | Stavros Sachtouris | @patch('%s.servers_action_post' % cyclades_pkg, return_value=FR()) |
277 | c390cb98 | Stavros Sachtouris | def test_get_server_console(self, SP): |
278 | 33ebcd22 | Stavros Sachtouris | cnsl = dict(console=dict(info1='i1', info2='i2', info3='i3')) |
279 | 975270f2 | Stavros Sachtouris | FR.json = cnsl |
280 | 33ebcd22 | Stavros Sachtouris | vm_id = vm_recv['server']['id'] |
281 | 975270f2 | Stavros Sachtouris | r = self.client.get_server_console(vm_id)
|
282 | fb392083 | Stavros Sachtouris | SP.assert_called_once_with( |
283 | 6290b789 | Stavros Sachtouris | vm_id, json_data=dict(console=dict(type='vnc')), success=200) |
284 | c390cb98 | Stavros Sachtouris | self.assert_dicts_are_equal(r, cnsl['console']) |
285 | c1004a00 | Stavros Sachtouris | |
286 | c1004a00 | Stavros Sachtouris | def test_get_firewall_profile(self): |
287 | 7d768bc6 | Stavros Sachtouris | vm_id = vm_recv['server']['id'] |
288 | bcef3ac9 | Stavros Sachtouris | v = firewalls['attachments'][0]['firewallProfile'] |
289 | 7d768bc6 | Stavros Sachtouris | with patch.object(
|
290 | 3c50df2e | Stavros Sachtouris | cyclades.CycladesClient, 'get_server_details',
|
291 | 852d2713 | Stavros Sachtouris | return_value=firewalls) as GSD:
|
292 | 7d768bc6 | Stavros Sachtouris | r = self.client.get_firewall_profile(vm_id)
|
293 | fb392083 | Stavros Sachtouris | GSD.assert_called_once_with(vm_id) |
294 | 7d768bc6 | Stavros Sachtouris | self.assertEqual(r, v)
|
295 | 852d2713 | Stavros Sachtouris | with patch.object(
|
296 | 3c50df2e | Stavros Sachtouris | cyclades.CycladesClient, 'get_server_details',
|
297 | 852d2713 | Stavros Sachtouris | return_value=dict()):
|
298 | 7d768bc6 | Stavros Sachtouris | self.assertRaises(
|
299 | 975270f2 | Stavros Sachtouris | ClientError, |
300 | 975270f2 | Stavros Sachtouris | self.client.get_firewall_profile,
|
301 | 7d768bc6 | Stavros Sachtouris | vm_id) |
302 | c1004a00 | Stavros Sachtouris | |
303 | 6290b789 | Stavros Sachtouris | @patch('%s.servers_action_post' % cyclades_pkg, return_value=FR()) |
304 | 153910c8 | Stavros Sachtouris | def test_set_firewall_profile(self, SP): |
305 | 278f2eb3 | Stavros Sachtouris | vm_id = vm_recv['server']['id'] |
306 | bcef3ac9 | Stavros Sachtouris | v = firewalls['attachments'][0]['firewallProfile'] |
307 | 975270f2 | Stavros Sachtouris | self.client.set_firewall_profile(vm_id, v)
|
308 | 6290b789 | Stavros Sachtouris | SP.assert_called_once_with(vm_id, json_data=dict(
|
309 | 6290b789 | Stavros Sachtouris | firewallProfile=dict(profile=v)), success=202) |
310 | 975270f2 | Stavros Sachtouris | |
311 | 18a27c41 | Stavros Sachtouris | @patch('%s.networks_post' % cyclades_pkg, return_value=FR()) |
312 | 18a27c41 | Stavros Sachtouris | def test_create_network(self, NP): |
313 | 975270f2 | Stavros Sachtouris | net_name = net_send['network']['name'] |
314 | 975270f2 | Stavros Sachtouris | FR.json = net_recv |
315 | 975270f2 | Stavros Sachtouris | full_args = dict(
|
316 | 975270f2 | Stavros Sachtouris | cidr='192.168.0.0/24',
|
317 | 975270f2 | Stavros Sachtouris | gateway='192.168.0.1',
|
318 | 975270f2 | Stavros Sachtouris | type='MAC_FILTERED',
|
319 | 975270f2 | Stavros Sachtouris | dhcp=True)
|
320 | 975270f2 | Stavros Sachtouris | test_args = dict(full_args)
|
321 | 975270f2 | Stavros Sachtouris | test_args.update(dict(empty=None, full=None)) |
322 | f6f81cd3 | Stavros Sachtouris | net_exp = dict(dhcp=False, name=net_name, type='MAC_FILTERED') |
323 | 975270f2 | Stavros Sachtouris | for arg, val in test_args.items(): |
324 | 975270f2 | Stavros Sachtouris | kwargs = {} if arg == 'empty' else full_args if ( |
325 | 975270f2 | Stavros Sachtouris | arg == 'full') else {arg: val} |
326 | 18a27c41 | Stavros Sachtouris | expected = dict(network=dict(net_exp)) |
327 | 18a27c41 | Stavros Sachtouris | expected['network'].update(kwargs)
|
328 | 975270f2 | Stavros Sachtouris | r = self.client.create_network(net_name, **kwargs)
|
329 | 27f04e4f | Stavros Sachtouris | self.assertEqual(
|
330 | 18a27c41 | Stavros Sachtouris | NP.mock_calls[-1],
|
331 | 18a27c41 | Stavros Sachtouris | call(json_data=expected, success=202))
|
332 | 975270f2 | Stavros Sachtouris | self.assert_dicts_are_equal(r, net_recv['network']) |
333 | c1004a00 | Stavros Sachtouris | |
334 | 850d58c7 | Stavros Sachtouris | @patch('%s.networks_post' % cyclades_pkg, return_value=FR()) |
335 | 850d58c7 | Stavros Sachtouris | def test_connect_server(self, NP): |
336 | 0e8a5f03 | Stavros Sachtouris | vm_id = vm_recv['server']['id'] |
337 | 0e8a5f03 | Stavros Sachtouris | net_id = net_recv['network']['id'] |
338 | 975270f2 | Stavros Sachtouris | self.client.connect_server(vm_id, net_id)
|
339 | fb392083 | Stavros Sachtouris | NP.assert_called_once_with( |
340 | 850d58c7 | Stavros Sachtouris | net_id, 'action',
|
341 | fb392083 | Stavros Sachtouris | json_data=dict(add=dict(serverRef=vm_id))) |
342 | 975270f2 | Stavros Sachtouris | |
343 | 975270f2 | Stavros Sachtouris | @patch('%s.networks_post' % cyclades_pkg, return_value=FR()) |
344 | 975270f2 | Stavros Sachtouris | def test_disconnect_server(self, NP): |
345 | b87ed277 | Stavros Sachtouris | net_id, vm_id = net_recv['network']['id'], vm_recv['server']['id'] |
346 | 9ced0bd8 | Stavros Sachtouris | nic_id = 'nic-%s-%s' % (net_id, vm_id)
|
347 | 9ced0bd8 | Stavros Sachtouris | vm_nics = [ |
348 | 9ced0bd8 | Stavros Sachtouris | dict(id=nic_id, network_id=net_id),
|
349 | 9ced0bd8 | Stavros Sachtouris | dict(id='another-nic-id', network_id='another-net-id'), |
350 | 9ced0bd8 | Stavros Sachtouris | dict(id=nic_id * 2, network_id=net_id * 2)] |
351 | 9ced0bd8 | Stavros Sachtouris | with patch.object(
|
352 | 3c50df2e | Stavros Sachtouris | cyclades.CycladesClient, |
353 | 9ced0bd8 | Stavros Sachtouris | 'list_server_nics',
|
354 | 975270f2 | Stavros Sachtouris | return_value=vm_nics) as LSN:
|
355 | 975270f2 | Stavros Sachtouris | r = self.client.disconnect_server(vm_id, nic_id)
|
356 | fb392083 | Stavros Sachtouris | LSN.assert_called_once_with(vm_id) |
357 | fb392083 | Stavros Sachtouris | NP.assert_called_once_with( |
358 | b87ed277 | Stavros Sachtouris | net_id, 'action',
|
359 | fb392083 | Stavros Sachtouris | json_data=dict(remove=dict(attachment=nic_id))) |
360 | fb392083 | Stavros Sachtouris | self.assertEqual(r, 1) |
361 | 0da4f84b | Stavros Sachtouris | |
362 | 6290b789 | Stavros Sachtouris | @patch('%s.servers_ips_get' % cyclades_pkg, return_value=FR()) |
363 | a5c8ec5d | Stavros Sachtouris | def test_list_server_nics(self, SG): |
364 | 975270f2 | Stavros Sachtouris | vm_id = vm_recv['server']['id'] |
365 | c088076b | Stavros Sachtouris | nics = dict(attachments=[dict(id='nic1'), dict(id='nic2')]) |
366 | 975270f2 | Stavros Sachtouris | FR.json = nics |
367 | 975270f2 | Stavros Sachtouris | r = self.client.list_server_nics(vm_id)
|
368 | 6290b789 | Stavros Sachtouris | SG.assert_called_once_with(vm_id) |
369 | c088076b | Stavros Sachtouris | expected = nics['attachments']
|
370 | 975270f2 | Stavros Sachtouris | for i in range(len(r)): |
371 | 975270f2 | Stavros Sachtouris | self.assert_dicts_are_equal(r[i], expected[i])
|
372 | a5c8ec5d | Stavros Sachtouris | self.assertEqual(i + 1, len(r)) |
373 | 975270f2 | Stavros Sachtouris | |
374 | dce00f54 | Stavros Sachtouris | @patch('%s.networks_get' % cyclades_pkg, return_value=FR()) |
375 | dce00f54 | Stavros Sachtouris | def test_list_networks(self, NG): |
376 | 975270f2 | Stavros Sachtouris | FR.json = net_list |
377 | bcef3ac9 | Stavros Sachtouris | expected = net_list['networks']
|
378 | dce00f54 | Stavros Sachtouris | for detail in ('', 'detail'): |
379 | dce00f54 | Stavros Sachtouris | r = self.client.list_networks(detail=True if detail else False) |
380 | dce00f54 | Stavros Sachtouris | self.assertEqual(NG.mock_calls[-1], call(command=detail)) |
381 | dce00f54 | Stavros Sachtouris | for i, net in enumerate(expected): |
382 | dce00f54 | Stavros Sachtouris | self.assert_dicts_are_equal(r[i], net)
|
383 | dce00f54 | Stavros Sachtouris | self.assertEqual(i + 1, len(r)) |
384 | 975270f2 | Stavros Sachtouris | |
385 | 99d462c6 | Stavros Sachtouris | @patch('%s.networks_get' % cyclades_pkg, return_value=FR()) |
386 | 99d462c6 | Stavros Sachtouris | def test_list_network_nics(self, NG): |
387 | c6f8aeb4 | Stavros Sachtouris | net_id = net_recv['network']['id'] |
388 | 975270f2 | Stavros Sachtouris | FR.json = net_recv |
389 | 975270f2 | Stavros Sachtouris | r = self.client.list_network_nics(net_id)
|
390 | be7599cf | Stavros Sachtouris | NG.assert_called_once_with(network_id=net_id) |
391 | bcef3ac9 | Stavros Sachtouris | expected = net_recv['network']['attachments'] |
392 | 975270f2 | Stavros Sachtouris | for i in range(len(r)): |
393 | 975270f2 | Stavros Sachtouris | self.assert_dicts_are_equal(r[i], expected[i])
|
394 | 975270f2 | Stavros Sachtouris | |
395 | 975270f2 | Stavros Sachtouris | @patch('%s.networks_post' % cyclades_pkg, return_value=FR()) |
396 | 975270f2 | Stavros Sachtouris | def test_disconnect_network_nics(self, NP): |
397 | 9794e66a | Stavros Sachtouris | net_id = net_recv['network']['id'] |
398 | 9794e66a | Stavros Sachtouris | nics = ['nic1', 'nic2', 'nic3'] |
399 | 9794e66a | Stavros Sachtouris | with patch.object(
|
400 | 3c50df2e | Stavros Sachtouris | cyclades.CycladesClient, |
401 | 9794e66a | Stavros Sachtouris | 'list_network_nics',
|
402 | be7599cf | Stavros Sachtouris | return_value=nics) as LNN:
|
403 | 975270f2 | Stavros Sachtouris | self.client.disconnect_network_nics(net_id)
|
404 | be7599cf | Stavros Sachtouris | LNN.assert_called_once_with(net_id) |
405 | 975270f2 | Stavros Sachtouris | for i in range(len(nics)): |
406 | 975270f2 | Stavros Sachtouris | expected = call(net_id, 'action', json_data=dict( |
407 | 975270f2 | Stavros Sachtouris | remove=dict(attachment=nics[i])))
|
408 | 975270f2 | Stavros Sachtouris | self.assertEqual(expected, NP.mock_calls[i])
|
409 | 975270f2 | Stavros Sachtouris | |
410 | be7599cf | Stavros Sachtouris | @patch('%s.networks_get' % cyclades_pkg, return_value=FR()) |
411 | 5f4fcc1b | Stavros Sachtouris | def test_get_network_details(self, NG): |
412 | 975270f2 | Stavros Sachtouris | FR.json = net_recv |
413 | 65cc246b | Stavros Sachtouris | net_id = net_recv['network']['id'] |
414 | 975270f2 | Stavros Sachtouris | r = self.client.get_network_details(net_id)
|
415 | 5f4fcc1b | Stavros Sachtouris | NG.assert_called_once_with(network_id=net_id) |
416 | 975270f2 | Stavros Sachtouris | self.assert_dicts_are_equal(r, net_recv['network']) |
417 | 975270f2 | Stavros Sachtouris | |
418 | fb392083 | Stavros Sachtouris | @patch('%s.networks_put' % cyclades_pkg, return_value=FR()) |
419 | fb392083 | Stavros Sachtouris | def test_update_network_name(self, NP): |
420 | 06030a1b | Stavros Sachtouris | net_id = net_recv['network']['id'] |
421 | 06030a1b | Stavros Sachtouris | new_name = '%s_new' % net_id
|
422 | 975270f2 | Stavros Sachtouris | self.client.update_network_name(net_id, new_name)
|
423 | fb392083 | Stavros Sachtouris | NP.assert_called_once_with( |
424 | fb392083 | Stavros Sachtouris | network_id=net_id, |
425 | fb392083 | Stavros Sachtouris | json_data=dict(network=dict(name=new_name))) |
426 | 975270f2 | Stavros Sachtouris | |
427 | f15a4776 | Stavros Sachtouris | def test_delete_network(self): |
428 | c23f1dec | Stavros Sachtouris | net_id = net_recv['network']['id'] |
429 | f15a4776 | Stavros Sachtouris | with patch.object(
|
430 | 3c50df2e | Stavros Sachtouris | cyclades.CycladesClient, 'networks_delete',
|
431 | f15a4776 | Stavros Sachtouris | return_value=FR()) as ND:
|
432 | f15a4776 | Stavros Sachtouris | self.client.delete_network(net_id)
|
433 | f15a4776 | Stavros Sachtouris | ND.assert_called_once_with(net_id) |
434 | f15a4776 | Stavros Sachtouris | with patch.object(
|
435 | 3c50df2e | Stavros Sachtouris | cyclades.CycladesClient, 'networks_delete',
|
436 | f15a4776 | Stavros Sachtouris | side_effect=ClientError('A 421 Error', 421)): |
437 | f15a4776 | Stavros Sachtouris | try:
|
438 | f15a4776 | Stavros Sachtouris | self.client.delete_network(421) |
439 | f15a4776 | Stavros Sachtouris | except ClientError as err: |
440 | f15a4776 | Stavros Sachtouris | self.assertEqual(err.status, 421) |
441 | f15a4776 | Stavros Sachtouris | self.assertEqual(err.details, [
|
442 | f15a4776 | Stavros Sachtouris | 'Network may be still connected to at least one server'])
|
443 | 975270f2 | Stavros Sachtouris | |
444 | 03033b54 | Stavros Sachtouris | @patch('%s.floating_ip_pools_get' % cyclades_pkg, return_value=FR()) |
445 | 03033b54 | Stavros Sachtouris | def test_get_floating_ip_pools(self, get): |
446 | 03033b54 | Stavros Sachtouris | r = self.client.get_floating_ip_pools()
|
447 | 03033b54 | Stavros Sachtouris | self.assert_dicts_are_equal(r, FR.json)
|
448 | 03033b54 | Stavros Sachtouris | self.assertEqual(get.mock_calls[-1], call()) |
449 | 03033b54 | Stavros Sachtouris | |
450 | 03033b54 | Stavros Sachtouris | @patch('%s.floating_ips_get' % cyclades_pkg, return_value=FR()) |
451 | 03033b54 | Stavros Sachtouris | def test_get_floating_ips(self, get): |
452 | 03033b54 | Stavros Sachtouris | r = self.client.get_floating_ips()
|
453 | 03033b54 | Stavros Sachtouris | self.assert_dicts_are_equal(r, FR.json)
|
454 | 03033b54 | Stavros Sachtouris | self.assertEqual(get.mock_calls[-1], call()) |
455 | 03033b54 | Stavros Sachtouris | |
456 | 03033b54 | Stavros Sachtouris | @patch('%s.floating_ips_post' % cyclades_pkg, return_value=FR()) |
457 | 03033b54 | Stavros Sachtouris | def test_alloc_floating_ip(self, post): |
458 | 03033b54 | Stavros Sachtouris | FR.json = dict(floating_ip=dict( |
459 | 03033b54 | Stavros Sachtouris | fixed_ip='fip',
|
460 | 03033b54 | Stavros Sachtouris | id=1,
|
461 | 03033b54 | Stavros Sachtouris | instance_id='lala',
|
462 | 03033b54 | Stavros Sachtouris | ip='102.0.0.1',
|
463 | 03033b54 | Stavros Sachtouris | pool='pisine'))
|
464 | 03033b54 | Stavros Sachtouris | for args in product( |
465 | 03033b54 | Stavros Sachtouris | (None, 'pisine'), |
466 | 03033b54 | Stavros Sachtouris | (None, 'Iwannanip')): |
467 | 03033b54 | Stavros Sachtouris | r = self.client.alloc_floating_ip(*args)
|
468 | 03033b54 | Stavros Sachtouris | pool, address = args |
469 | 03033b54 | Stavros Sachtouris | self.assert_dicts_are_equal(r, FR.json['floating_ip']) |
470 | 03033b54 | Stavros Sachtouris | json_data = dict()
|
471 | 03033b54 | Stavros Sachtouris | if pool:
|
472 | 03033b54 | Stavros Sachtouris | json_data['pool'] = pool
|
473 | 7d4ebdab | Stavros Sachtouris | if address:
|
474 | 7d4ebdab | Stavros Sachtouris | json_data['address'] = address
|
475 | 03033b54 | Stavros Sachtouris | self.assertEqual(post.mock_calls[-1], call(json_data)) |
476 | 03033b54 | Stavros Sachtouris | |
477 | 03033b54 | Stavros Sachtouris | @patch('%s.floating_ips_get' % cyclades_pkg, return_value=FR()) |
478 | 03033b54 | Stavros Sachtouris | def test_get_floating_ip(self, get): |
479 | 03033b54 | Stavros Sachtouris | FR.json = dict(floating_ip=dict( |
480 | 03033b54 | Stavros Sachtouris | fixed_ip='fip',
|
481 | 03033b54 | Stavros Sachtouris | id=1,
|
482 | 03033b54 | Stavros Sachtouris | instance_id='lala',
|
483 | 03033b54 | Stavros Sachtouris | ip='102.0.0.1',
|
484 | 03033b54 | Stavros Sachtouris | pool='pisine'))
|
485 | 03033b54 | Stavros Sachtouris | self.assertRaises(AssertionError, self.client.get_floating_ip, None) |
486 | 03033b54 | Stavros Sachtouris | fip = 'fip'
|
487 | 03033b54 | Stavros Sachtouris | r = self.client.get_floating_ip(fip)
|
488 | 03033b54 | Stavros Sachtouris | self.assert_dicts_are_equal(r, FR.json['floating_ip']) |
489 | 03033b54 | Stavros Sachtouris | self.assertEqual(get.mock_calls[-1], call(fip)) |
490 | 03033b54 | Stavros Sachtouris | |
491 | 03033b54 | Stavros Sachtouris | @patch('%s.floating_ips_delete' % cyclades_pkg, return_value=FR()) |
492 | 03033b54 | Stavros Sachtouris | def test_delete_floating_ip(self, delete): |
493 | 03033b54 | Stavros Sachtouris | self.assertRaises(AssertionError, self.client.delete_floating_ip, None) |
494 | 03033b54 | Stavros Sachtouris | fip = 'fip'
|
495 | 03033b54 | Stavros Sachtouris | r = self.client.delete_floating_ip(fip)
|
496 | 03033b54 | Stavros Sachtouris | self.assert_dicts_are_equal(r, FR.headers)
|
497 | 03033b54 | Stavros Sachtouris | self.assertEqual(delete.mock_calls[-1], call(fip)) |
498 | 03033b54 | Stavros Sachtouris | |
499 | 6290b789 | Stavros Sachtouris | @patch('%s.servers_action_post' % cyclades_pkg, return_value=FR()) |
500 | 8b2d63a7 | Stavros Sachtouris | def test_attach_floating_ip(self, spost): |
501 | 03033b54 | Stavros Sachtouris | vmid, addr = 42, 'anIpAddress' |
502 | 03033b54 | Stavros Sachtouris | for err, args in { |
503 | 03033b54 | Stavros Sachtouris | ValueError: ['not a server id', addr], |
504 | 03033b54 | Stavros Sachtouris | TypeError: [None, addr], |
505 | 03033b54 | Stavros Sachtouris | AssertionError: [vmid, None], |
506 | 03033b54 | Stavros Sachtouris | AssertionError: [vmid, '']}.items(): |
507 | 03033b54 | Stavros Sachtouris | self.assertRaises(
|
508 | 8b2d63a7 | Stavros Sachtouris | err, self.client.attach_floating_ip, *args)
|
509 | 8b2d63a7 | Stavros Sachtouris | r = self.client.attach_floating_ip(vmid, addr)
|
510 | 03033b54 | Stavros Sachtouris | self.assert_dicts_are_equal(r, FR.headers)
|
511 | 03033b54 | Stavros Sachtouris | expected = dict(addFloatingIp=dict(address=addr)) |
512 | 6290b789 | Stavros Sachtouris | self.assertEqual(spost.mock_calls[-1], call(vmid, json_data=expected)) |
513 | 03033b54 | Stavros Sachtouris | |
514 | 6290b789 | Stavros Sachtouris | @patch('%s.servers_action_post' % cyclades_pkg, return_value=FR()) |
515 | 8b2d63a7 | Stavros Sachtouris | def test_detach_floating_ip(self, spost): |
516 | 03033b54 | Stavros Sachtouris | vmid, addr = 42, 'anIpAddress' |
517 | 03033b54 | Stavros Sachtouris | for err, args in { |
518 | 03033b54 | Stavros Sachtouris | ValueError: ['not a server id', addr], |
519 | 03033b54 | Stavros Sachtouris | TypeError: [None, addr], |
520 | 03033b54 | Stavros Sachtouris | AssertionError: [vmid, None], |
521 | 03033b54 | Stavros Sachtouris | AssertionError: [vmid, '']}.items(): |
522 | 03033b54 | Stavros Sachtouris | self.assertRaises(
|
523 | 8b2d63a7 | Stavros Sachtouris | err, self.client.detach_floating_ip, *args)
|
524 | 8b2d63a7 | Stavros Sachtouris | r = self.client.detach_floating_ip(vmid, addr)
|
525 | 03033b54 | Stavros Sachtouris | self.assert_dicts_are_equal(r, FR.headers)
|
526 | 03033b54 | Stavros Sachtouris | expected = dict(removeFloatingIp=dict(address=addr)) |
527 | 6290b789 | Stavros Sachtouris | self.assertEqual(spost.mock_calls[-1], call(vmid, json_data=expected)) |
528 | 03033b54 | Stavros Sachtouris | |
529 | 68fd1bda | Stavros Sachtouris | |
530 | 85898ca4 | Stavros Sachtouris | if __name__ == '__main__': |
531 | 85898ca4 | Stavros Sachtouris | from sys import argv |
532 | 85898ca4 | Stavros Sachtouris | from kamaki.clients.test import runTestCase |
533 | 68fd1bda | Stavros Sachtouris | not_found = True
|
534 | 3c50df2e | Stavros Sachtouris | if not argv[1:] or argv[1] == 'CycladesClient': |
535 | 68fd1bda | Stavros Sachtouris | not_found = False
|
536 | 3c50df2e | Stavros Sachtouris | runTestCase(CycladesClient, 'Cyclades Client', argv[2:]) |
537 | 3c50df2e | Stavros Sachtouris | if not argv[1:] or argv[1] == 'CycladesRestClient': |
538 | 68fd1bda | Stavros Sachtouris | not_found = False
|
539 | 3c50df2e | Stavros Sachtouris | runTestCase(CycladesRestClient, 'CycladesRest Client', argv[2:]) |
540 | 68fd1bda | Stavros Sachtouris | if not_found:
|
541 | 68fd1bda | Stavros Sachtouris | print('TestCase %s not found' % argv[1]) |