¡@

Home 

OpenStack Study: test_sdnve_plugin.py

OpenStack Index

**** CubicPower OpenStack Study ****

# Copyright 2014 IBM Corp.

#

# All Rights Reserved.

#

# Licensed under the Apache License, Version 2.0 (the "License"); you may

# not use this file except in compliance with the License. You may obtain

# a copy of the License at

#

# http://www.apache.org/licenses/LICENSE-2.0

#

# Unless required by applicable law or agreed to in writing, software

# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT

# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the

# License for the specific language governing permissions and limitations

# under the License.

#

# @author: Mohammad Banikazemi, IBM Corp

import contextlib

import mock

from neutron.extensions import portbindings

from neutron.tests.unit import _test_extension_portbindings as test_bindings

from neutron.tests.unit import test_db_plugin as test_plugin

from neutron.tests.unit import test_l3_plugin as test_l3_plugin

from neutron.plugins.ibm.common import constants

_plugin_name = ('neutron.plugins.ibm.'

'sdnve_neutron_plugin.SdnvePluginV2')

HTTP_OK = 200

**** CubicPower OpenStack Study ****

class MockClient(object):

**** CubicPower OpenStack Study ****

    def sdnve_list(self, resource, **params):

        return (HTTP_OK, 'body')

**** CubicPower OpenStack Study ****

    def sdnve_show(self, resource, specific, **params):

        return (HTTP_OK, 'body')

**** CubicPower OpenStack Study ****

    def sdnve_create(self, resource, body):

        return (HTTP_OK, 'body')

**** CubicPower OpenStack Study ****

    def sdnve_update(self, resource, specific, body=None):

        return (HTTP_OK, 'body')

**** CubicPower OpenStack Study ****

    def sdnve_delete(self, resource, specific):

        return (HTTP_OK, 'body')

**** CubicPower OpenStack Study ****

    def sdnve_get_tenant_byid(self, os_tenant_id):

        return (os_tenant_id, constants.TENANT_TYPE_OF)

**** CubicPower OpenStack Study ****

    def sdnve_check_and_create_tenant(

        self, os_tenant_id, network_type=None):

        return os_tenant_id

**** CubicPower OpenStack Study ****

    def sdnve_get_controller(self):

        return

**** CubicPower OpenStack Study ****

class MockKeystoneClient(object):

**** CubicPower OpenStack Study ****

    def __init__(self, **kwargs):

        pass

**** CubicPower OpenStack Study ****

    def get_tenant_type(self, id):

        return constants.TENANT_TYPE_OF

**** CubicPower OpenStack Study ****

    def get_tenant_name(self, id):

        return "tenant name"

**** CubicPower OpenStack Study ****

class IBMPluginV2TestCase(test_plugin.NeutronDbPluginV2TestCase):

**** CubicPower OpenStack Study ****

    def setUp(self):

        with contextlib.nested(

            mock.patch('neutron.plugins.ibm.sdnve_api.'

                       'KeystoneClient',

                       new=MockKeystoneClient),

            mock.patch('neutron.plugins.ibm.sdnve_api.'

                       'Client',

                       new=MockClient)):

            super(IBMPluginV2TestCase, self).setUp(plugin=_plugin_name)

**** CubicPower OpenStack Study ****

class TestIBMBasicGet(test_plugin.TestBasicGet, IBMPluginV2TestCase):

pass

**** CubicPower OpenStack Study ****

class TestIBMV2HTTPResponse(test_plugin.TestV2HTTPResponse, IBMPluginV2TestCase):

pass

**** CubicPower OpenStack Study ****

class TestIBMNetworksV2(test_plugin.TestNetworksV2, IBMPluginV2TestCase):

pass

**** CubicPower OpenStack Study ****

class TestIBMPortsV2(test_plugin.TestPortsV2, IBMPluginV2TestCase):

pass

**** CubicPower OpenStack Study ****

class TestIBMSubnetsV2(test_plugin.TestSubnetsV2, IBMPluginV2TestCase):

pass

**** CubicPower OpenStack Study ****

class TestIBMPortBinding(IBMPluginV2TestCase, test_bindings.PortBindingsTestCase):

VIF_TYPE = portbindings.VIF_TYPE_OVS

**** CubicPower OpenStack Study ****

class IBMPluginRouterTestCase(test_l3_plugin.L3NatDBIntTestCase):

**** CubicPower OpenStack Study ****

    def setUp(self):

        with contextlib.nested(

            mock.patch('neutron.plugins.ibm.sdnve_api.'

                       'KeystoneClient',

                       new=MockKeystoneClient),

            mock.patch('neutron.plugins.ibm.sdnve_api.'

                       'Client',

                       new=MockClient)):

            super(IBMPluginRouterTestCase, self).setUp(plugin=_plugin_name)