4483fe5006
This patch is based on https://review.openstack.org/161194 It renames vmware_nsx/tests/unit/vmware/ to vmware_nsx/tests/unit/ and creates subdirectories vmware_nsx/tests/unit/dvs/ vmware_nsx/tests/unit/nsx_mh/ vmware_nsx/tests/unit/nsx_v/ vmware_nsx/tests/unit/nsx_v3/ vmware_nsx/tests/unit/nsxlib/mh/ vmware_nsx/tests/unit/nsxlib/v3/ This is part of new vmware_nsx directory structure proposed in https://goo.gl/GdWXyH. Change-Id: I16aa2455bce55f6455bb5e504ee9684c675b4257
61 lines
2.4 KiB
Python
61 lines
2.4 KiB
Python
# Copyright (c) 2014 VMware, Inc.
|
|
#
|
|
# 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.
|
|
#
|
|
|
|
from neutron.tests import base
|
|
|
|
from vmware_nsx.api_client import (
|
|
version as version_module)
|
|
from vmware_nsx.api_client import exception
|
|
from vmware_nsx.nsxlib.mh import router as routerlib
|
|
from vmware_nsx.nsxlib.mh import versioning
|
|
|
|
|
|
class TestVersioning(base.BaseTestCase):
|
|
|
|
def test_function_handling_missing_minor(self):
|
|
version = version_module.Version('2.0')
|
|
function = versioning.get_function_by_version(
|
|
routerlib.ROUTER_FUNC_DICT, 'create_lrouter', version)
|
|
self.assertEqual(routerlib.create_implicit_routing_lrouter,
|
|
function)
|
|
|
|
def test_function_handling_with_both_major_and_minor(self):
|
|
version = version_module.Version('3.2')
|
|
function = versioning.get_function_by_version(
|
|
routerlib.ROUTER_FUNC_DICT, 'create_lrouter', version)
|
|
self.assertEqual(routerlib.create_explicit_routing_lrouter,
|
|
function)
|
|
|
|
def test_function_handling_with_newer_major(self):
|
|
version = version_module.Version('5.2')
|
|
function = versioning.get_function_by_version(
|
|
routerlib.ROUTER_FUNC_DICT, 'create_lrouter', version)
|
|
self.assertEqual(routerlib.create_explicit_routing_lrouter,
|
|
function)
|
|
|
|
def test_function_handling_with_obsolete_major(self):
|
|
version = version_module.Version('1.2')
|
|
self.assertRaises(NotImplementedError,
|
|
versioning.get_function_by_version,
|
|
routerlib.ROUTER_FUNC_DICT,
|
|
'create_lrouter', version)
|
|
|
|
def test_function_handling_with_unknown_version(self):
|
|
self.assertRaises(exception.ServiceUnavailable,
|
|
versioning.get_function_by_version,
|
|
routerlib.ROUTER_FUNC_DICT,
|
|
'create_lrouter', None)
|