SEBA-497 delayering, Makefile, and tox for fabric-synchronizer
Change-Id: I916f4b632019dddceae5a6f024a0b1c64d8188d8
diff --git a/xos/synchronizer/model_policies/test_model_policy_compute_node.py b/xos/synchronizer/model_policies/test_model_policy_compute_node.py
index 9b17d8d..4c8b41e 100644
--- a/xos/synchronizer/model_policies/test_model_policy_compute_node.py
+++ b/xos/synchronizer/model_policies/test_model_policy_compute_node.py
@@ -13,14 +13,18 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+#from __future__ import absolute_import
+import imp
import unittest
import ipaddress
-from mock import patch, call, Mock, PropertyMock
+from mock import patch, Mock
-import os, sys
+import os
+import sys
-test_path=os.path.abspath(os.path.dirname(os.path.realpath(__file__)))
+test_path = os.path.abspath(os.path.dirname(os.path.realpath(__file__)))
+
class TestComputeNodePolicy(unittest.TestCase):
def setUp(self):
@@ -38,8 +42,8 @@
import xossynchronizer.modelaccessor
import mock_modelaccessor
- reload(mock_modelaccessor) # in case nose2 loaded it in a previous test
- reload(xossynchronizer.modelaccessor) # in case nose2 loaded it in a previous test
+ imp.reload(mock_modelaccessor) # in case nose2 loaded it in a previous test
+ imp.reload(xossynchronizer.modelaccessor) # in case nose2 loaded it in a previous test
from model_policy_compute_nodes import ComputeNodePolicy, model_accessor
@@ -51,8 +55,8 @@
for (k, v) in model_accessor.all_model_classes.items():
globals()[k] = v
- # Some of the functions we call have side-effects. For example, creating a VSGServiceInstance may lead to creation of
- # tags. Ideally, this wouldn't happen, but it does. So make sure we reset the world.
+ # Some of the functions we call have side-effects. For example, creating a VSGServiceInstance may lead to
+ # creation of tags. Ideally, this wouldn't happen, but it does. So make sure we reset the world.
model_accessor.reset_all_object_stores()
self.policy = ComputeNodePolicy
@@ -63,7 +67,7 @@
def test_getLastAddress(self):
- dataPlaneIp = unicode("10.6.1.2/24", "utf-8")
+ dataPlaneIp = u"10.6.1.2/24"
interface = ipaddress.ip_interface(dataPlaneIp)
subnet = ipaddress.ip_network(interface.network)
last_ip = self.policy.getLastAddress(subnet)
@@ -71,7 +75,7 @@
def test_generateVlan(self):
- used_vlans = range(16, 4093)
+ used_vlans = list(range(16, 4093))
used_vlans.remove(1000)
vlan = self.policy.generateVlan(used_vlans)
@@ -80,7 +84,7 @@
def test_generateVlanFail(self):
- used_vlans = range(16, 4093)
+ used_vlans = list(range(16, 4093))
with self.assertRaises(Exception) as e:
self.policy.generateVlan(used_vlans)
@@ -89,13 +93,13 @@
def test_getVlanByCidr_same_subnet(self):
- mock_pi_ip = unicode("10.6.1.2/24", "utf-8")
-
+ mock_pi_ip = u"10.6.1.2/24"
+
mock_pi = Mock()
mock_pi.vlanUntagged = 1234
mock_pi.ips = str(self.policy.getPortCidrByIp(mock_pi_ip))
- test_ip = unicode("10.6.1.1/24", "utf-8")
+ test_ip = u"10.6.1.1/24"
test_subnet = self.policy.getPortCidrByIp(test_ip)
with patch.object(PortInterface.objects, "get_items") as get_pi:
@@ -106,12 +110,12 @@
def test_getVlanByCidr_different_subnet(self):
- mock_pi_ip = unicode("10.6.1.2/24", "utf-8")
+ mock_pi_ip = u"10.6.1.2/24"
mock_pi = Mock()
mock_pi.vlanUntagged = 1234
mock_pi.ips = str(self.policy.getPortCidrByIp(mock_pi_ip))
- test_ip = unicode("192.168.1.1/24", "utf-8")
+ test_ip = u"192.168.1.1/24"
test_subnet = self.policy.getPortCidrByIp(test_ip)
with patch.object(PortInterface.objects, "get_items") as get_pi:
@@ -130,7 +134,7 @@
def test_handle_update_do_nothing(self):
- mock_pi_ip = unicode("10.6.1.2/24", "utf-8")
+ mock_pi_ip = u"10.6.1.2/24"
mock_pi = Mock()
mock_pi.port_id = 1
mock_pi.name = "test_interface"
@@ -142,8 +146,8 @@
self.model.node.dataPlaneIntf = "test_interface"
with patch.object(PortInterface.objects, "get_items") as get_pi, \
- patch.object(self.policy, "getPortCidrByIp") as get_subnet, \
- patch.object(PortInterface, 'save') as mock_save:
+ patch.object(self.policy, "getPortCidrByIp") as get_subnet, \
+ patch.object(PortInterface, 'save') as mock_save:
get_pi.return_value = [mock_pi]
get_subnet.return_value = mock_pi.ips
@@ -158,11 +162,11 @@
self.model.port.id = 1
self.model.node.dataPlaneIntf = "test_interface"
- self.model.node.dataPlaneIp = unicode("10.6.1.2/24", "utf-8")
+ self.model.node.dataPlaneIp = u"10.6.1.2/24"
with patch.object(PortInterface.objects, "get_items") as get_pi, \
- patch.object(self.policy, "getVlanByCidr") as get_vlan, \
- patch.object(PortInterface, "save", autospec=True) as mock_save:
+ patch.object(self.policy, "getVlanByCidr") as get_vlan, \
+ patch.object(PortInterface, "save", autospec=True) as mock_save:
get_pi.return_value = []
get_vlan.return_value = "1234"
@@ -181,4 +185,3 @@
if __name__ == '__main__':
sys.path.append("../steps") # so we can import helpers from steps directory
unittest.main()
-