Revision e57893cd snf-cyclades-app/synnefo/api/test/floating_ips.py
b/snf-cyclades-app/synnefo/api/test/floating_ips.py | ||
---|---|---|
38 | 38 |
from synnefo.db.models_factory import (FloatingIPFactory, NetworkFactory, |
39 | 39 |
VirtualMachineFactory, |
40 | 40 |
NetworkInterfaceFactory) |
41 |
from mock import patch |
|
41 |
from mock import patch, Mock
|
|
42 | 42 |
|
43 | 43 |
|
44 | 44 |
URL = "/api/v1.1/os-floating-ips" |
... | ... | |
184 | 184 |
ips_after = FloatingIP.objects.filter(id=ip.id) |
185 | 185 |
self.assertEqual(len(ips_after), 0) |
186 | 186 |
|
187 |
@patch("synnefo.logic.backend", Mock()) |
|
188 |
def test_delete_network_with_floating_ips(self): |
|
189 |
ip = FloatingIPFactory(machine=None) |
|
190 |
net = ip.network |
|
191 |
# Can not remove network with floating IPs |
|
192 |
with mocked_quotaholder(): |
|
193 |
response = self.delete("/api/v1.1/networks/%s" % net.id, |
|
194 |
net.userid) |
|
195 |
self.assertFault(response, 421, "networkInUse") |
|
196 |
# But we can with only deleted Floating Ips |
|
197 |
ip.deleted = True |
|
198 |
ip.save() |
|
199 |
with mocked_quotaholder(): |
|
200 |
response = self.delete("/api/v1.1/networks/%s" % net.id, |
|
201 |
net.userid) |
|
202 |
self.assertSuccess(response) |
|
203 |
|
|
187 | 204 |
|
188 | 205 |
POOLS_URL = "/api/v1.1/os-floating-ip-pools" |
189 | 206 |
|
Also available in: Unified diff