Fix unit tests for networking-odl

This commits fixes problems with the unit tests not running correctly
as a result of some changes to neutron using new oslo libraries, as well
as some fundamental problems post refactoring of the neutron ODL parts.

Change-Id: I926b278b6ae25e6d10a58df4bfb69315da168265
Closes-Bug: #1411780
This commit is contained in:
Kyle Mestery
2015-01-23 00:36:53 +00:00
parent 71490b8e90
commit c6a0e4394e
2 changed files with 7 additions and 5 deletions

View File

@@ -13,6 +13,9 @@
# License for the specific language governing permissions and limitations
# under the License.
from networking_odl.common import client
from networking_odl.ml2 import mech_driver
import mock
from oslo.serialization import jsonutils
import requests
@@ -42,8 +45,7 @@ class OpenDaylightTestCase(test_plugin.Ml2PluginV2TestCase):
super(OpenDaylightTestCase, self).setUp()
self.port_create_status = 'DOWN'
self.mech = mechanism_odl.OpenDaylightMechanismDriver()
mechanism_odl.OpenDaylightMechanismDriver.sendjson = (
self.check_sendjson)
client.OpenDaylightRestClient.sendjson = (self.check_sendjson)
def check_sendjson(self, method, urlpath, obj, ignorecodes=[]):
self.assertFalse(urlpath.startswith("http://"))
@@ -111,7 +113,7 @@ class DataMatcher(object):
def __init__(self, operation, object_type, context):
self._data = context.current.copy()
self._object_type = object_type
filter_map = getattr(mechanism_odl.OpenDaylightMechanismDriver,
filter_map = getattr(mech_driver.OpenDaylightDriver,
'%s_object_map' % operation)
attr_filter = filter_map["%ss" % object_type]
attr_filter(self._data, context)
@@ -220,7 +222,7 @@ class OpenDaylightMechanismDriverTestCase(base.BaseTestCase):
def _test_single_operation(self, method, context, status_code,
exc_class=None, *args, **kwargs):
self.mech.out_of_sync = False
self.mech.odl_drv.out_of_sync = False
request_response = self._get_mock_request_response(status_code)
with mock.patch('requests.request',
return_value=request_response) as mock_method:

View File

@@ -3,4 +3,4 @@
TESTRARGS=$1
exec 3>&1
status=$(exec 4>&1 >&3; ( python -m neutron.openstack.common.lockutils python setup.py testr --slowest --testr-args="--subunit $TESTRARGS"; echo $? >&4 ) | $(dirname $0)/subunit-trace.py -f) && exit $status
status=$(exec 4>&1 >&3; ( python setup.py testr --slowest --testr-args="--subunit $TESTRARGS"; echo $? >&4 ) | $(dirname $0)/subunit-trace.py -f) && exit $status