summaryrefslogtreecommitdiffstats
path: root/nova/tests
diff options
context:
space:
mode:
authorAlex Meade <alex.meade@rackspace.com>2011-07-13 09:24:32 -0400
committerAlex Meade <alex.meade@rackspace.com>2011-07-13 09:24:32 -0400
commitc0ba788ca2a25899578f729b00b7d8e2cd0a682a (patch)
tree804a3e93bae1aa87b7c2cfa72c9a09b9cc9ed9e9 /nova/tests
parentc085294ccb6a8d449ccfd5739be67ee12538f48f (diff)
parentb58e853038e9c322be765600e225568689e5c479 (diff)
merged trunk
Diffstat (limited to 'nova/tests')
-rw-r--r--nova/tests/api/openstack/contrib/test_multinic_xs.py10
-rw-r--r--nova/tests/test_network.py33
2 files changed, 37 insertions, 6 deletions
diff --git a/nova/tests/api/openstack/contrib/test_multinic_xs.py b/nova/tests/api/openstack/contrib/test_multinic_xs.py
index 484cd1c17..b0a9f7676 100644
--- a/nova/tests/api/openstack/contrib/test_multinic_xs.py
+++ b/nova/tests/api/openstack/contrib/test_multinic_xs.py
@@ -50,9 +50,8 @@ class FixedIpTest(test.TestCase):
fakes.stub_out_auth(self.stubs)
self.stubs.Set(compute.api.API, "add_fixed_ip",
compute_api_add_fixed_ip)
- # TODO(Vek): Fails until remove_fixed_ip() added
- # self.stubs.Set(compute.api.API, "remove_fixed_ip",
- # compute_api_remove_fixed_ip)
+ self.stubs.Set(compute.api.API, "remove_fixed_ip",
+ compute_api_remove_fixed_ip)
self.context = context.get_admin_context()
def tearDown(self):
@@ -98,9 +97,8 @@ class FixedIpTest(test.TestCase):
req.headers['content-type'] = 'application/json'
resp = req.get_response(fakes.wsgi_app())
- # TODO(Vek): Fails until remove_fixed_ip() added
- # self.assertEqual(resp.status_int, 202)
- # self.assertEqual(last_remove_fixed_ip, ('test_inst', '10.10.10.1'))
+ self.assertEqual(resp.status_int, 202)
+ self.assertEqual(last_remove_fixed_ip, ('test_inst', '10.10.10.1'))
def test_remove_fixed_ip_no_address(self):
global last_remove_fixed_ip
diff --git a/nova/tests/test_network.py b/nova/tests/test_network.py
index 6d5166019..b09021e13 100644
--- a/nova/tests/test_network.py
+++ b/nova/tests/test_network.py
@@ -16,6 +16,7 @@
# under the License.
from nova import db
+from nova import exception
from nova import flags
from nova import log as logging
from nova import test
@@ -238,3 +239,35 @@ class VlanNetworkTestCase(test.TestCase):
self.assertRaises(ValueError, self.network.create_networks, None,
num_networks=100, vlan_start=1,
cidr='192.168.0.1/24', network_size=100)
+
+
+class CommonNetworkTestCase(test.TestCase):
+
+ class FakeNetworkManager(network_manager.NetworkManager):
+ """This NetworkManager doesn't call the base class so we can bypass all
+ inherited service cruft and just perform unit tests.
+ """
+
+ class FakeDB:
+ def fixed_ip_get_by_instance(self, context, instance_id):
+ return [dict(address='10.0.0.0'), dict(address='10.0.0.1'),
+ dict(address='10.0.0.2')]
+
+ def __init__(self):
+ self.db = self.FakeDB()
+ self.deallocate_called = None
+
+ def deallocate_fixed_ip(self, context, address):
+ self.deallocate_called = address
+
+ def test_remove_fixed_ip_from_instance(self):
+ manager = self.FakeNetworkManager()
+ manager.remove_fixed_ip_from_instance(None, 99, '10.0.0.1')
+
+ self.assertEquals(manager.deallocate_called, '10.0.0.1')
+
+ def test_remove_fixed_ip_from_instance_bad_input(self):
+ manager = self.FakeNetworkManager()
+ self.assertRaises(exception.FixedIpNotFoundForSpecificInstance,
+ manager.remove_fixed_ip_from_instance,
+ None, 99, 'bad input')