vmware-nsx/quantum/tests/unit/bigswitch/test_restproxy_plugin.py
Zhongyue Luo 13aef4e028 Replaces assertEquals to assertEqual
assertEquals() has been deprecated in 2.7
Replaced assertEquals to assertEqual in all test scripts

Change-Id: I04b4ac873e151837ade9127f8c1eba32f4707dd4
2012-12-14 10:05:10 +08:00

113 lines
3.0 KiB
Python

# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2012 Big Switch Networks, Inc.
# 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.
import os
from mock import patch
import quantum.common.test_lib as test_lib
from quantum.manager import QuantumManager
import quantum.tests.unit.test_db_plugin as test_plugin
RESTPROXY_PKG_PATH = 'quantum.plugins.bigswitch.plugin'
class HTTPResponseMock():
status = 200
reason = 'OK'
def __init__(self, sock, debuglevel=0, strict=0, method=None,
buffering=False):
pass
def read(self):
return "{'status': '200 OK'}"
class HTTPConnectionMock():
def __init__(self, server, port, timeout):
pass
def request(self, action, uri, body, headers):
return
def getresponse(self):
return HTTPResponseMock(None)
def close(self):
pass
class BigSwitchProxyPluginV2TestCase(test_plugin.QuantumDbPluginV2TestCase):
_plugin_name = ('%s.QuantumRestProxyV2' % RESTPROXY_PKG_PATH)
def setUp(self):
etc_path = os.path.join(os.path.dirname(__file__), 'etc')
test_lib.test_config['config_files'] = [os.path.join(etc_path,
'restproxy.ini.test')]
self.httpPatch = patch('httplib.HTTPConnection', create=True,
new=HTTPConnectionMock)
MockHTTPConnection = self.httpPatch.start()
super(BigSwitchProxyPluginV2TestCase,
self).setUp(self._plugin_name)
def tearDown(self):
super(BigSwitchProxyPluginV2TestCase, self).tearDown()
self.httpPatch.stop()
class TestBigSwitchProxyBasicGet(test_plugin.TestBasicGet,
BigSwitchProxyPluginV2TestCase):
pass
class TestBigSwitchProxyV2HTTPResponse(test_plugin.TestV2HTTPResponse,
BigSwitchProxyPluginV2TestCase):
pass
class TestBigSwitchProxyPortsV2(test_plugin.TestPortsV2,
BigSwitchProxyPluginV2TestCase):
pass
class TestBigSwitchProxyNetworksV2(test_plugin.TestNetworksV2,
BigSwitchProxyPluginV2TestCase):
pass
class TestBigSwitchProxySubnetsV2(test_plugin.TestSubnetsV2,
BigSwitchProxyPluginV2TestCase):
pass
class TestBigSwitchProxySync(BigSwitchProxyPluginV2TestCase):
def test_send_data(self):
plugin_obj = QuantumManager.get_plugin()
result = plugin_obj._send_all_data()
self.assertEqual(result[0], 200)