From 98ef56332d7fdb551f8a4beb6d411ce141583c10 Mon Sep 17 00:00:00 2001 From: Jamie Lennox Date: Fri, 9 May 2014 16:34:09 +1000 Subject: [PATCH] Convert floating IP pool tests to httpretty Change-Id: Ic9332ddd30a0bc3ffc5ed7c046f60ded3f940e85 blueprint: httpretty-testing --- novaclient/tests/fixture_data/floatingips.py | 18 ++++++++++++++++++ .../tests/v1_1/test_floating_ip_pools.py | 13 +++++++------ 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/novaclient/tests/fixture_data/floatingips.py b/novaclient/tests/fixture_data/floatingips.py index a74b82913..8dd590427 100644 --- a/novaclient/tests/fixture_data/floatingips.py +++ b/novaclient/tests/fixture_data/floatingips.py @@ -196,3 +196,21 @@ class BulkFixture(base.Fixture): httpretty.register_uri(httpretty.POST, self.url(), body=post_os_floating_ips_bulk, content_type='application/json') + + +class PoolsFixture(base.Fixture): + + base_url = 'os-floating-ip-pools' + + def setUp(self): + super(PoolsFixture, self).setUp() + + get_os_floating_ip_pools = { + 'floating_ip_pools': [ + {'name': 'foo'}, + {'name': 'bar'} + ] + } + httpretty.register_uri(httpretty.GET, self.url(), + body=jsonutils.dumps(get_os_floating_ip_pools), + content_type='application/json') diff --git a/novaclient/tests/v1_1/test_floating_ip_pools.py b/novaclient/tests/v1_1/test_floating_ip_pools.py index 51124cfc9..efdfabf30 100644 --- a/novaclient/tests/v1_1/test_floating_ip_pools.py +++ b/novaclient/tests/v1_1/test_floating_ip_pools.py @@ -14,18 +14,19 @@ # License for the specific language governing permissions and limitations # under the License. +from novaclient.tests.fixture_data import client +from novaclient.tests.fixture_data import floatingips as data from novaclient.tests import utils -from novaclient.tests.v1_1 import fakes from novaclient.v1_1 import floating_ip_pools -cs = fakes.FakeClient() +class TestFloatingIPPools(utils.FixturedTestCase): - -class TestFloatingIPPools(utils.TestCase): + client_fixture_class = client.V1 + data_fixture_class = data.PoolsFixture def test_list_floating_ips(self): - fl = cs.floating_ip_pools.list() - cs.assert_called('GET', '/os-floating-ip-pools') + fl = self.cs.floating_ip_pools.list() + self.assert_called('GET', '/os-floating-ip-pools') [self.assertIsInstance(f, floating_ip_pools.FloatingIPPool) for f in fl]