Пример #1
0
 def test_delete_floating_ip(self):
     self.instance.get_port = mock.Mock(return_value=fake_port)
     url = test_base._get_path('floatingips', id=fake_floating_ip_id)
     resp = self._test_send_msg(None, 'delete', url)
     self.instance.delete_floatingip.\
         assert_called_once_with(mock.ANY, fake_floating_ip_id)
     self.assertEqual(resp.status_int, exc.HTTPNoContent.code)
Пример #2
0
    def test_update_floating_ip(self):
        fake_floating_ip_update_info = {'port_id': None}
        floatingip_info = copy.deepcopy(fake_floating_ip['floatingip'])
        floatingip_info.update(fake_floating_ip_update_info)
        floatingip_info.update({
            'status': 'ACTIVE',
            'tenant_id': fake_tenant_id,
            'floating_network_id': fake_network_id,
            'fixed_ip_address': None,
            'floating_ip_address': '172.24.4.228'
        })

        self.instance.update_floatingip.return_value = floatingip_info
        self.instance.get_port = mock.Mock(return_value=fake_port)
        floating_ip_request = {'floatingip': fake_floating_ip_update_info}
        url = test_base._get_path('floatingips',
                                  id=fake_floating_ip_id,
                                  fmt=self.fmt)
        resp = self._test_send_msg(floating_ip_request, 'put', url)
        self.instance.update_floatingip.\
            assert_called_once_with(mock.ANY,
                                    fake_floating_ip_id,
                                    floatingip=floating_ip_request)
        self._verify_resp(resp, exc.HTTPOk.code, 'floatingip',
                          fake_floating_ip_id)
 def test_delete_floating_ip(self):
     self.instance.get_port = mock.Mock(return_value=fake_port)
     url = test_base._get_path('floatingips', id=fake_floating_ip_id)
     resp = self._test_send_msg(None, 'delete', url)
     self.instance.delete_floatingip.\
         assert_called_once_with(mock.ANY, fake_floating_ip_id)
     self.assertEqual(resp.status_int, exc.HTTPNoContent.code)
Пример #4
0
 def _post_network_with_provider_attrs(self, ctx, expect_errors=False):
     data = self._prepare_net_data()
     env = {'neutron.context': ctx}
     res = self.api.post(test_base._get_path('networks', fmt=self.fmt),
                         self.serialize({'network': data}),
                         content_type='application/' + self.fmt,
                         extra_environ=env,
                         expect_errors=expect_errors)
     return res, data
 def test_health_monitor_delete(self):
     entity_id = _uuid()
     res = self.api.delete(
         test_base._get_path('lbaas/healthmonitors',
                             id=entity_id, fmt=self.fmt))
     delete_entity = getattr(self.plugin.return_value,
                             "delete_healthmonitor")
     delete_entity.assert_called_with(mock.ANY, entity_id)
     self.assertEqual(exc.HTTPNoContent.code, res.status_int)
 def test_health_monitor_delete(self):
     entity_id = _uuid()
     res = self.api.delete(
         test_base._get_path('lbaas/healthmonitors',
                             id=entity_id, fmt=self.fmt))
     delete_entity = getattr(self.plugin.return_value,
                             "delete_healthmonitor")
     delete_entity.assert_called_with(mock.ANY, entity_id)
     self.assertEqual(exc.HTTPNoContent.code, res.status_int)
Пример #7
0
 def test_pool_member_delete(self):
     entity_id = _uuid()
     res = self.api.delete(
         test_base._get_path('lbaas/pools/pid1/members',
                             id=entity_id,
                             fmt=self.fmt))
     delete_entity = getattr(self.plugin.return_value, "delete_pool_member")
     delete_entity.assert_called_with(mock.ANY, entity_id, pool_id='pid1')
     self.assertEqual(exc.HTTPNoContent.code, res.status_int)
 def test_pool_member_delete(self):
     entity_id = _uuid()
     res = self.api.delete(
         test_base._get_path('lbaas/pools/pid1/members',
                             id=entity_id, fmt=self.fmt))
     delete_entity = getattr(self.plugin.return_value,
                             "delete_pool_member")
     delete_entity.assert_called_with(mock.ANY, entity_id,
                                      pool_id='pid1')
     self.assertEqual(exc.HTTPNoContent.code, res.status_int)
Пример #9
0
 def _test_entity_delete(self, entity):
     """Does the entity deletion based on naming convention."""
     entity_id = str(uuid.uuid4())
     path = self._resource_prefix + "/" if self._resource_prefix else ""
     path += self._plural_mappings.get(entity, entity + "s")
     if self._translate_resource_name:
         path = path.replace("_", "-")
     res = self.api.delete(test_base._get_path(path, id=entity_id, fmt=self.fmt))
     delete_entity = getattr(self.plugin.return_value, "delete_" + entity)
     delete_entity.assert_called_with(mock.ANY, entity_id)
     self.assertEqual(res.status_int, exc.HTTPNoContent.code)
Пример #10
0
 def test_create_router(self):
     router_info = copy.deepcopy(fake_router_object['router'])
     router_info.update({'status': 'ACTIVE', 'id': fake_router_uuid})
     self.instance.create_router.return_value = router_info
     self.instance.get_routers_count.return_value = 0
     url = test_base._get_path('routers', fmt=self.fmt)
     resp = self._test_send_msg(fake_router_object, 'post', url)
     self.instance.create_router.\
         assert_called_once_with(mock.ANY, router=fake_router_object)
     self._verify_resp(resp, exc.HTTPCreated.code, 'router',
                       fake_router_uuid)
Пример #11
0
    def test_delete_floating_ip(self):
        floating_ip_id, floating_ip = self._get_floating_ip_test()

        instance = self.plugin.return_value
        instance.get_floatingip = mock.Mock(return_value=floating_ip)
        res = self.api.delete(
            test_base._get_path('floatingips', id=floating_ip_id))
        instance.delete_floatingip.assert_called_once_with(
            mock.ANY, floating_ip_id)

        self.assertEqual(exc.HTTPNoContent.code, res.status_int)
Пример #12
0
 def test_create_router(self):
     router_info = copy.deepcopy(fake_router_object['router'])
     router_info.update({'status': 'ACTIVE', 'id': fake_router_uuid})
     self.instance.create_router.return_value = router_info
     self.instance.get_routers_count.return_value = 0
     url = test_base._get_path('routers', fmt=self.fmt)
     resp = self._test_send_msg(fake_router_object, 'post', url)
     self.instance.create_router. \
         assert_called_once_with(mock.ANY, router=fake_router_object)
     self._verify_resp(resp, exc.HTTPCreated.code,
                       'router', fake_router_uuid)
Пример #13
0
 def _test_entity_delete(self, entity):
     """Does the entity deletion based on naming convention."""
     entity_id = uuidutils.generate_uuid()
     path = self._resource_prefix + '/' if self._resource_prefix else ''
     path += self._plural_mappings.get(entity, entity + 's')
     if self._translate_resource_name:
         path = path.replace('_', '-')
     res = self.api.delete(
         test_base._get_path(path, id=entity_id, fmt=self.fmt))
     delete_entity = getattr(self.plugin.return_value, "delete_" + entity)
     delete_entity.assert_called_with(mock.ANY, entity_id)
     self.assertEqual(exc.HTTPNoContent.code, res.status_int)
Пример #14
0
 def test_update_router(self):
     router_info = copy.deepcopy(fake_router_object['router'])
     router_info.update(fake_router_external_info)
     router_info.update({'status': 'ACTIVE', 'id': fake_router_uuid})
     self.instance.update_router.return_value = router_info
     router_request = {'router': fake_router_external_info}
     url = test_base._get_path('routers', id=fake_router_uuid, fmt=self.fmt)
     resp = self._test_send_msg(router_request, 'put', url)
     self.instance.update_router.\
         assert_called_once_with(mock.ANY, fake_router_uuid,
                                 router=router_request)
     self._verify_resp(resp, exc.HTTPOk.code, 'router', fake_router_uuid)
Пример #15
0
 def test_update_router(self):
     router_info = copy.deepcopy(fake_router_object['router'])
     router_info.update(fake_router_external_info)
     router_info.update({'status': 'ACTIVE', 'id': fake_router_uuid})
     self.instance.update_router.return_value = router_info
     router_request = {'router': fake_router_external_info}
     url = test_base._get_path('routers', id=fake_router_uuid, fmt=self.fmt)
     resp = self._test_send_msg(router_request, 'put', url)
     self.instance.update_router. \
         assert_called_once_with(mock.ANY, fake_router_uuid,
                                 router=router_request)
     self._verify_resp(resp, exc.HTTPOk.code, 'router', fake_router_uuid)
Пример #16
0
 def _test_entity_delete(self, entity):
     """Does the entity deletion based on naming convention."""
     entity_id = str(uuid.uuid4())
     path = self._resource_prefix + '/' if self._resource_prefix else ''
     path += self._plural_mappings.get(entity, entity + 's')
     if self._translate_resource_name:
         path = path.replace('_', '-')
     res = self.api.delete(
         test_base._get_path(path, id=entity_id, fmt=self.fmt))
     delete_entity = getattr(self.plugin.return_value, "delete_" + entity)
     delete_entity.assert_called_with(mock.ANY, entity_id)
     self.assertEqual(res.status_int, exc.HTTPNoContent.code)
Пример #17
0
 def test_remove_router_interface(self):
     interface_info = {'tenant_id': fake_tenant_id,
                       'id': fake_router_uuid}
     interface_info.update(fake_interface_remove)
     self.instance.remove_router_interface.return_value = interface_info
     url = test_base._get_path('routers', id=fake_router_uuid,
                               action='remove_router_interface',
                               fmt=self.fmt)
     resp = self._test_send_msg(fake_interface_remove, 'put', url)
     self.instance.remove_router_interface. \
         assert_called_once_with(mock.ANY, fake_router_uuid,
                                 fake_interface_remove)
     self._verify_resp(resp, exc.HTTPOk.code, None, fake_router_uuid)
Пример #18
0
 def test_remove_router_interface(self):
     interface_info = {'tenant_id': fake_tenant_id, 'id': fake_router_uuid}
     interface_info.update(fake_interface_remove)
     self.instance.remove_router_interface.return_value = interface_info
     url = test_base._get_path('routers',
                               id=fake_router_uuid,
                               action='remove_router_interface',
                               fmt=self.fmt)
     resp = self._test_send_msg(fake_interface_remove, 'put', url)
     self.instance.remove_router_interface.\
         assert_called_once_with(mock.ANY, fake_router_uuid,
                                 fake_interface_remove)
     self._verify_resp(resp, exc.HTTPOk.code, None, fake_router_uuid)
Пример #19
0
 def _put_network_with_provider_attrs(self, ctx, expect_errors=False):
     data = self._prepare_net_data()
     env = {'neutron.context': ctx}
     instance = self.plugin.return_value
     instance.get_network.return_value = {'tenant_id': ctx.tenant_id,
                                          'shared': False}
     net_id = uuidutils.generate_uuid()
     res = self.api.put(test_base._get_path('networks',
                                            id=net_id,
                                            fmt=self.fmt),
                        self.serialize({'network': data}),
                        extra_environ=env,
                        expect_errors=expect_errors)
     return res, data, net_id
    def test_create_floating_ip(self):
        floatingip_info = copy.deepcopy(fake_floating_ip['floatingip'])
        floatingip_info.update(fake_floating_ip_update_info)
        floatingip_info.update({'status': 'ACTIVE', 'fixed_ip_address': None})

        self.instance.create_floatingip.return_value = floatingip_info
        self.instance.get_floatingips_count.return_value = 0
        self.instance.get_port = mock.Mock(return_value=fake_port)

        floating_ip_request = {'floatingip': fake_floating_ip_update_info}
        url = test_base._get_path('floatingips', fmt=self.fmt)
        resp = self._test_send_msg(floating_ip_request, 'post', url)
        self.instance.create_floatingip.\
            assert_called_once_with(mock.ANY,
                                    floatingip=floating_ip_request)
        self._verify_resp(resp, exc.HTTPCreated.code,
                          'floatingip', fake_floating_ip_id)
Пример #21
0
    def test_create_floating_ip(self):
        floatingip_info = copy.deepcopy(fake_floating_ip['floatingip'])
        floatingip_info.update(fake_floating_ip_update_info)
        floatingip_info.update({'status': 'ACTIVE', 'fixed_ip_address': None})

        self.instance.create_floatingip.return_value = floatingip_info
        self.instance.get_floatingips_count.return_value = 0
        self.instance.get_port = mock.Mock(return_value=fake_port)

        floating_ip_request = {'floatingip': fake_floating_ip_update_info}
        url = test_base._get_path('floatingips', fmt=self.fmt)
        resp = self._test_send_msg(floating_ip_request, 'post', url)
        self.instance.create_floatingip.\
            assert_called_once_with(mock.ANY,
                                    floatingip=floating_ip_request)
        self._verify_resp(resp, exc.HTTPCreated.code, 'floatingip',
                          fake_floating_ip_id)
Пример #22
0
    def test_update_floating_ip(self):
        floating_ip_id, floating_ip = self._get_floating_ip_test()

        floating_ip_request_info = {"port_id": None}

        return_value = copy.deepcopy(floating_ip['floatingip'])
        return_value.update(floating_ip_request_info)
        return_value.update({
            "status": "ACTIVE",
            "tenant_id": "test-tenant",
            "floating_network_id": "376da547-b977-4cfe-9cba-275c80debf57",
            "fixed_ip_address": None,
            "floating_ip_address": "172.24.4.228"
        })

        instance = self.plugin.return_value
        instance.get_floatingip = mock.Mock(return_value=floating_ip)
        instance.update_floatingip.return_value = return_value
        port_id, port = self._get_port_test()
        instance.get_port = mock.Mock(return_value=port)

        floating_ip_request = {'floatingip': floating_ip_request_info}

        res = self.api.put(
            test_base._get_path('floatingips', id=floating_ip_id,
                                fmt=self.fmt),
            self.serialize(floating_ip_request))

        instance.update_floatingip.\
            assert_called_once_with(mock.ANY,
                                    floating_ip_id,
                                    floatingip=floating_ip_request)

        self.assertEqual(exc.HTTPOk.code, res.status_int)
        res = self.deserialize(res)
        self.assertIn('floatingip', res)
        floatingip = res['floatingip']
        self.assertEqual(floating_ip_id, floatingip['id'])
        self.assertIsNone(floatingip['port_id'])
        self.assertIsNone(floatingip['fixed_ip_address'])
    def test_update_floating_ip(self):
        fake_floating_ip_update_info = {'port_id': None}
        floatingip_info = copy.deepcopy(fake_floating_ip['floatingip'])
        floatingip_info.update(fake_floating_ip_update_info)
        floatingip_info.update({'status': 'ACTIVE',
                                'tenant_id': fake_tenant_id,
                                'floating_network_id': fake_network_id,
                                'fixed_ip_address': None,
                                'floating_ip_address': '172.24.4.228'})

        self.instance.update_floatingip.return_value = floatingip_info
        self.instance.get_port = mock.Mock(return_value=fake_port)
        floating_ip_request = {'floatingip': fake_floating_ip_update_info}
        url = test_base._get_path('floatingips',
                                  id=fake_floating_ip_id, fmt=self.fmt)
        resp = self._test_send_msg(floating_ip_request, 'put', url)
        self.instance.update_floatingip.\
            assert_called_once_with(mock.ANY,
                                    fake_floating_ip_id,
                                    floatingip=floating_ip_request)
        self._verify_resp(resp, exc.HTTPOk.code,
                          'floatingip', fake_floating_ip_id)
Пример #24
0
 def test_delete_router(self):
     url = test_base._get_path('routers', id=fake_router_uuid, fmt=self.fmt)
     resp = self._test_send_msg(None, 'delete', url)
     self.instance.delete_router.assert_called_once_with(mock.ANY,
                                                         fake_router_uuid)
     self.assertEqual(resp.status_int, exc.HTTPNoContent.code)
Пример #25
0
 def test_delete_router(self):
     url = test_base._get_path('routers', id=fake_router_uuid, fmt=self.fmt)
     resp = self._test_send_msg(None, 'delete', url)
     self.instance.delete_router.assert_called_once_with(
         mock.ANY, fake_router_uuid)
     self.assertEqual(resp.status_int, exc.HTTPNoContent.code)