Revision 9a73f94d snf-cyclades-app/synnefo/api/tests/floating_ips.py
b/snf-cyclades-app/synnefo/api/tests/floating_ips.py | ||
---|---|---|
67 | 67 |
def test_no_floating_ip(self): |
68 | 68 |
response = self.get(URL) |
69 | 69 |
self.assertSuccess(response) |
70 |
self.assertEqual(json.loads(response.content)["floating_ips"], [])
|
|
70 |
self.assertEqual(json.loads(response.content)["floatingips"], []) |
|
71 | 71 |
|
72 | 72 |
def test_list_ips(self): |
73 | 73 |
ip = mf.IPv4AddressFactory(userid="user1", floating_ip=True) |
74 | 74 |
with mocked_quotaholder(): |
75 | 75 |
response = self.get(URL, "user1") |
76 | 76 |
self.assertSuccess(response) |
77 |
api_ip = json.loads(response.content)["floating_ips"][0]
|
|
77 |
api_ip = json.loads(response.content)["floatingips"][0] |
|
78 | 78 |
self.assertEqual(api_ip, |
79 | 79 |
{"instance_id": str(ip.nic.machine_id), |
80 | 80 |
"floating_ip_address": ip.address, |
... | ... | |
88 | 88 |
with mocked_quotaholder(): |
89 | 89 |
response = self.get(URL + "/%s" % ip.id, "user1") |
90 | 90 |
self.assertSuccess(response) |
91 |
api_ip = json.loads(response.content)["floating_ip"]
|
|
91 |
api_ip = json.loads(response.content)["floatingip"] |
|
92 | 92 |
self.assertEqual(api_ip, |
93 | 93 |
{"instance_id": str(ip.nic.machine_id), |
94 | 94 |
"floating_ip_address": ip.address, |
... | ... | |
115 | 115 |
with mocked_quotaholder(): |
116 | 116 |
response = self.post(URL, "test_user", json.dumps(request), "json") |
117 | 117 |
self.assertSuccess(response) |
118 |
api_ip = json.loads(response.content, encoding="utf-8")["floating_ip"]
|
|
118 |
api_ip = json.loads(response.content, encoding="utf-8")["floatingip"] |
|
119 | 119 |
ip = floating_ips.get() |
120 | 120 |
self.assertEqual(ip.address, "192.168.2.2") |
121 | 121 |
self.assertEqual(ip.nic, None) |
... | ... | |
161 | 161 |
response = self.post(URL, "test_user", json.dumps(request), "json") |
162 | 162 |
self.assertSuccess(response) |
163 | 163 |
ip = floating_ips.get() |
164 |
self.assertEqual(json.loads(response.content)["floating_ip"],
|
|
164 |
self.assertEqual(json.loads(response.content)["floatingip"], |
|
165 | 165 |
{"instance_id": None, |
166 | 166 |
"floating_ip_address": "192.168.2.10", |
167 | 167 |
"fixed_ip_address": None, |
... | ... | |
193 | 193 |
response = self.post(URL, "test_user", json.dumps(request), "json") |
194 | 194 |
self.assertBadRequest(response) |
195 | 195 |
|
196 |
''' |
|
196 | 197 |
@patch("synnefo.db.models.get_rapi_client") |
197 | 198 |
def test_reserve_and_connect(self, mrapi): |
198 | 199 |
vm = mf.VirtualMachineFactory(userid="test_user") |
... | ... | |
203 | 204 |
} |
204 | 205 |
response = self.post(URL, "test_user", json.dumps(request), "json") |
205 | 206 |
ip = floating_ips.get() |
206 |
api_ip = json.loads(response.content, "utf-8")["floating_ip"]
|
|
207 |
api_ip = json.loads(response.content, "utf-8")["floatingip"] |
|
207 | 208 |
self.assertEqual(api_ip, |
208 | 209 |
{"instance_id": str(vm.id), |
209 | 210 |
"floating_ip_address": "192.168.2.12", |
... | ... | |
276 | 277 |
with mocked_quotaholder(): |
277 | 278 |
response = self.put(URL + "/%s" % ip.id, "user1", |
278 | 279 |
json.dumps(request), "json") |
279 |
print response.content |
|
280 | 280 |
self.assertEqual(response.status_code, 202) |
281 | 281 |
|
282 | 282 |
def test_update_dettach_unassociated(self): |
... | ... | |
293 | 293 |
with mocked_quotaholder(): |
294 | 294 |
response = self.delete(URL + "/%s" % ip.id, ip.userid) |
295 | 295 |
self.assertFault(response, 409, "conflict") |
296 |
''' |
|
297 |
|
|
298 |
def test_update(self): |
|
299 |
ip = mf.IPv4AddressFactory(userid="user1", floating_ip=True, nic=None) |
|
300 |
with mocked_quotaholder(): |
|
301 |
response = self.put(URL + "/%s" % ip.id, ip.userid) |
|
302 |
self.assertEqual(response.status_code, 501) |
|
296 | 303 |
|
297 | 304 |
def test_release(self): |
298 | 305 |
ip = mf.IPv4AddressFactory(userid="user1", floating_ip=True, nic=None) |
Also available in: Unified diff