SEBA-497 delayering, Makefile, and tox for fabric-crossconnect-synchronizer

Change-Id: Ibcf8fd06b9ad94d3f198887c18be7adfa4d5a954
diff --git a/xos/synchronizer/__init__.py b/xos/synchronizer/__init__.py
new file mode 100644
index 0000000..19d1424
--- /dev/null
+++ b/xos/synchronizer/__init__.py
@@ -0,0 +1,13 @@
+# Copyright 2019-present Open Networking Foundation
+#
+# 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.
diff --git a/xos/synchronizer/event_steps/__init__.py b/xos/synchronizer/event_steps/__init__.py
new file mode 100644
index 0000000..19d1424
--- /dev/null
+++ b/xos/synchronizer/event_steps/__init__.py
@@ -0,0 +1,13 @@
+# Copyright 2019-present Open Networking Foundation
+#
+# 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.
diff --git a/xos/synchronizer/event_steps/kubernetes_event.py b/xos/synchronizer/event_steps/kubernetes_event.py
index b3aae1a..4452636 100644
--- a/xos/synchronizer/event_steps/kubernetes_event.py
+++ b/xos/synchronizer/event_steps/kubernetes_event.py
@@ -15,8 +15,6 @@
 
 
 import json
-import os
-import sys
 from xossynchronizer.event_steps.eventstep import EventStep
 from xossynchronizer.modelaccessor import FabricCrossconnectService, FabricCrossconnectServiceInstance, Service
 from xosconfig import Config
@@ -24,6 +22,7 @@
 
 log = create_logger(Config().get('logging'))
 
+
 class KubernetesPodDetailsEventStep(EventStep):
     topics = ["xos.kubernetes.pod-details"]
     technology = "kafka"
@@ -63,6 +62,11 @@
 
             for service_instance in service.service_instances.all():
                 log.info("Dirtying FabricCrossconnectServiceInstance", service_instance=service_instance)
-                service_instance.backend_code=0
-                service_instance.backend_status="resynchronize due to kubernetes event"
-                service_instance.save(update_fields=["updated", "backend_code", "backend_status"], always_update_timestamp=True)
+                service_instance.backend_code = 0
+                service_instance.backend_status = "resynchronize due to kubernetes event"
+                service_instance.save(
+                    update_fields=[
+                        "updated",
+                        "backend_code",
+                        "backend_status"],
+                    always_update_timestamp=True)
diff --git a/xos/synchronizer/event_steps/test_kubernetes_event.py b/xos/synchronizer/event_steps/test_kubernetes_event.py
index 1d45ce5..2de7157 100644
--- a/xos/synchronizer/event_steps/test_kubernetes_event.py
+++ b/xos/synchronizer/event_steps/test_kubernetes_event.py
@@ -14,13 +14,13 @@
 
 import unittest
 import json
-import functools
-from mock import patch, call, Mock, PropertyMock
-import requests_mock
+from mock import patch, call, 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 TestKubernetesEvent(unittest.TestCase):
 
@@ -42,7 +42,7 @@
 
         import xossynchronizer.modelaccessor
         import mock_modelaccessor
-        reload(mock_modelaccessor) # in case nose2 loaded it in a previous test
+        reload(mock_modelaccessor)  # in case nose2 loaded it in a previous test
         reload(xossynchronizer.modelaccessor)      # in case nose2 loaded it in a previous test
 
         from xossynchronizer.modelaccessor import model_accessor
@@ -60,10 +60,10 @@
 
         self.onos = ONOSService(name="myonos",
                                 id=1111,
-                                rest_hostname = "onos-url",
-                                rest_port = "8181",
-                                rest_username = "karaf",
-                                rest_password = "karaf",
+                                rest_hostname="onos-url",
+                                rest_port="8181",
+                                rest_username="karaf",
+                                rest_password="karaf",
                                 backend_code=1,
                                 backend_status="succeeded")
 
@@ -92,8 +92,8 @@
 
     def test_process_event(self):
         with patch.object(FabricCrossconnectService.objects, "get_items") as fcservice_objects, \
-             patch.object(Service.objects, "get_items") as service_objects, \
-             patch.object(FabricCrossconnectServiceInstance, "save", autospec=True) as fcsi_save:
+                patch.object(Service.objects, "get_items") as service_objects, \
+                patch.object(FabricCrossconnectServiceInstance, "save", autospec=True) as fcsi_save:
             fcservice_objects.return_value = [self.fcservice]
             service_objects.return_value = [self.onos, self.fcservice]
 
@@ -112,14 +112,14 @@
             self.assertEqual(self.fcsi2.backend_status, "resynchronize due to kubernetes event")
 
             fcsi_save.assert_has_calls([call(self.fcsi1, update_fields=["updated", "backend_code", "backend_status"],
-                                            always_update_timestamp=True),
-                                       call(self.fcsi2, update_fields=["updated", "backend_code", "backend_status"],
-                                            always_update_timestamp=True)])
+                                             always_update_timestamp=True),
+                                        call(self.fcsi2, update_fields=["updated", "backend_code", "backend_status"],
+                                             always_update_timestamp=True)])
 
     def test_process_event_unknownstatus(self):
         with patch.object(FabricCrossconnectService.objects, "get_items") as fcservice_objects, \
-             patch.object(Service.objects, "get_items") as service_objects, \
-             patch.object(FabricCrossconnectServiceInstance, "save") as fcsi_save:
+                patch.object(Service.objects, "get_items") as service_objects, \
+                patch.object(FabricCrossconnectServiceInstance, "save") as fcsi_save:
             fcservice_objects.return_value = [self.fcservice]
             service_objects.return_value = [self.onos, self.fcservice]
 
@@ -141,8 +141,8 @@
 
     def test_process_event_unknownservice(self):
         with patch.object(FabricCrossconnectService.objects, "get_items") as fcservice_objects, \
-             patch.object(Service.objects, "get_items") as service_objects, \
-             patch.object(FabricCrossconnectServiceInstance, "save") as fcsi_save:
+                patch.object(Service.objects, "get_items") as service_objects, \
+                patch.object(FabricCrossconnectServiceInstance, "save") as fcsi_save:
             fcservice_objects.return_value = [self.fcservice]
             service_objects.return_value = [self.onos, self.fcservice]
 
@@ -164,8 +164,8 @@
 
     def test_process_event_nolabels(self):
         with patch.object(FabricCrossconnectService.objects, "get_items") as fcservice_objects, \
-             patch.object(Service.objects, "get_items") as service_objects, \
-             patch.object(FabricCrossconnectServiceInstance, "save") as fcsi_save:
+                patch.object(Service.objects, "get_items") as service_objects, \
+                patch.object(FabricCrossconnectServiceInstance, "save") as fcsi_save:
             fcservice_objects.return_value = [self.fcservice]
             service_objects.return_value = [self.onos, self.fcservice]
 
@@ -184,8 +184,6 @@
 
             fcsi_save.assert_not_called()
 
+
 if __name__ == '__main__':
     unittest.main()
-
-
-
diff --git a/xos/synchronizer/model_policies/__init__.py b/xos/synchronizer/model_policies/__init__.py
new file mode 100644
index 0000000..19d1424
--- /dev/null
+++ b/xos/synchronizer/model_policies/__init__.py
@@ -0,0 +1,13 @@
+# Copyright 2019-present Open Networking Foundation
+#
+# 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.
diff --git a/xos/synchronizer/model_policies/model_policy_fabriccrossconnectserviceinstance.py b/xos/synchronizer/model_policies/model_policy_fabriccrossconnectserviceinstance.py
index caa34bd..612331f 100644
--- a/xos/synchronizer/model_policies/model_policy_fabriccrossconnectserviceinstance.py
+++ b/xos/synchronizer/model_policies/model_policy_fabriccrossconnectserviceinstance.py
@@ -16,13 +16,13 @@
 
 from xossynchronizer.modelaccessor import FabricCrossconnectServiceInstance, ServiceInstance, model_accessor
 from xossynchronizer.model_policies.policy import Policy
-from xossynchronizer.exceptions import *
 
 from xosconfig import Config
 from multistructlog import create_logger
 
 log = create_logger(Config().get('logging'))
 
+
 class FabricCrossconnectServiceInstancePolicy(Policy):
     model_name = "FabricCrossconnectServiceInstance"
 
@@ -41,5 +41,3 @@
 
     def handle_delete(self, service_instance):
         log.info("Handle_delete Fabric-Crossconnect Service Instance", service_instance=service_instance)
-
-
diff --git a/xos/synchronizer/model_policies/test_model_policy_fabriccrossconnectserviceinstance.py b/xos/synchronizer/model_policies/test_model_policy_fabriccrossconnectserviceinstance.py
index 9fe1418..93379f9 100644
--- a/xos/synchronizer/model_policies/test_model_policy_fabriccrossconnectserviceinstance.py
+++ b/xos/synchronizer/model_policies/test_model_policy_fabriccrossconnectserviceinstance.py
@@ -15,24 +15,25 @@
 import unittest
 
 import functools
-from mock import patch, call, Mock, PropertyMock, MagicMock
-import requests_mock
-import multistructlog
-from multistructlog import create_logger
+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__)))
+
 
 def mock_get_westbound_service_instance_properties(props, prop):
     return props[prop]
 
+
 def match_json(desired, req):
-    if desired!=req.json():
+    if desired != req.json():
         raise Exception("Got request %s, but body is not matching" % req.url)
         return False
     return True
 
+
 class TestPolicyFabricCrossconnectServiceInstance(unittest.TestCase):
 
     def setUp(self):
@@ -48,11 +49,11 @@
         # END Setting up the config module
 
         from xossynchronizer.mock_modelaccessor_build import mock_modelaccessor_config
-        mock_modelaccessor_config(test_path, [("fabric-crossconnect", "fabric-crossconnect.xproto"),])
+        mock_modelaccessor_config(test_path, [("fabric-crossconnect", "fabric-crossconnect.xproto"), ])
 
         import xossynchronizer.modelaccessor
         import mock_modelaccessor
-        reload(mock_modelaccessor) # in case nose2 loaded it in a previous test
+        reload(mock_modelaccessor)  # in case nose2 loaded it in a previous test
         reload(xossynchronizer.modelaccessor)      # in case nose2 loaded it in a previous test
 
         from model_policy_fabriccrossconnectserviceinstance import FabricCrossconnectServiceInstancePolicy, \
@@ -68,14 +69,14 @@
         self.policy_step.log = Mock()
 
         # mock onos-fabric
-        self.onos_fabric = Service(name = "onos-fabric",
-                              rest_hostname = "onos-fabric",
-                              rest_port = "8181",
-                              rest_username = "onos",
-                              rest_password = "rocks")
+        self.onos_fabric = Service(name="onos-fabric",
+                                   rest_hostname="onos-fabric",
+                                   rest_port="8181",
+                                   rest_username="onos",
+                                   rest_password="rocks")
 
-        self.service = FabricCrossconnectService(name = "fcservice",
-                                                 provider_services = [self.onos_fabric])
+        self.service = FabricCrossconnectService(name="fcservice",
+                                                 provider_services=[self.onos_fabric])
 
     def mock_westbound(self, fsi, s_tag, switch_datapath_id, switch_port):
         # Mock out a ServiceInstance so the syncstep can call get_westbound_service_instance_properties on it
@@ -86,20 +87,18 @@
              "switch_datapath_id": switch_datapath_id,
              "switch_port": switch_port})
 
-        fsi.provided_links=Mock(exists=Mock(return_value=True))
+        fsi.provided_links = Mock(exists=Mock(return_value=True))
 
         return si
 
     def test_handle_update(self):
-        with patch.object(ServiceInstance.objects, "get_items") as serviceinstance_objects, \
-            patch.object(FabricCrossconnectServiceInstance, "save") as fcsi_save:
-
+        with patch.object(ServiceInstance.objects, "get_items") as serviceinstance_objects:
             fsi = FabricCrossconnectServiceInstance(id=7777, owner=self.service, s_tag=None, source_port=None,
                                                     switch_datapath_id=None)
 
             serviceinstance_objects.return_value = [fsi]
 
-            si = self.mock_westbound(fsi, s_tag=111, switch_datapath_id = "of:0000000000000201", switch_port = 3)
+            si = self.mock_westbound(fsi, s_tag=111, switch_datapath_id="of:0000000000000201", switch_port=3)
             serviceinstance_objects.return_value = [si]
 
             self.policy_step(model_accessor=self.model_accessor).handle_update(fsi)
@@ -108,5 +107,6 @@
         self.o = None
         sys.path = self.sys_path_save
 
+
 if __name__ == '__main__':
     unittest.main()
diff --git a/xos/synchronizer/models/__init__.py b/xos/synchronizer/models/__init__.py
new file mode 100644
index 0000000..19d1424
--- /dev/null
+++ b/xos/synchronizer/models/__init__.py
@@ -0,0 +1,13 @@
+# Copyright 2019-present Open Networking Foundation
+#
+# 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.
diff --git a/xos/synchronizer/models/convenience/fabric_crossconnect_service.py b/xos/synchronizer/models/convenience/fabric_crossconnect_service.py
index c2bb8bf..863f40c 100644
--- a/xos/synchronizer/models/convenience/fabric_crossconnect_service.py
+++ b/xos/synchronizer/models/convenience/fabric_crossconnect_service.py
@@ -14,9 +14,10 @@
 # limitations under the License.
 
 
-from xosapi.orm import ORMWrapper, register_convenience_wrapper
+from xosapi.orm import register_convenience_wrapper
 from xosapi.convenience.service import ORMWrapperService
 
+
 class ORMWrapperFabricCrossconnectService(ORMWrapperService):
 
     """ Calling convention. Assume the subscribing service does approximately (needs some checks to see
@@ -45,9 +46,9 @@
             provider_service_instance = candidates[0]
         else:
             provider_service_instance = FabricCrossconnectServiceInstance(owner=self,
-                                                                        s_tag=s_tag,
-                                                                        switch_datapath_id=switch_datapath_id,
-                                                                        source_port=source_port)
+                                                                          s_tag=s_tag,
+                                                                          switch_datapath_id=switch_datapath_id,
+                                                                          source_port=source_port)
             provider_service_instance.save()
 
         # NOTE: Lack-of-atomicity vulnerability -- provider_service_instance could be deleted before we created the
@@ -77,7 +78,7 @@
             if link.provider_service_instance.owner.id == self.id:
                 fcsi = link.provider_service_instance.leaf_model
                 if (fcsi.s_tag == s_tag) and (fcsi.switch_datapath_id == switch_datapath_id) and \
-                    (fcsi.source_port == source_port):
+                        (fcsi.source_port == source_port):
                     matched.append(fcsi)
                 else:
                     link.delete()
@@ -91,7 +92,8 @@
         """
 
         s_tag = subscriber_si.get_westbound_service_instance_properties("s_tag", include_self=True)
-        switch_datapath_id = subscriber_si.get_westbound_service_instance_properties("switch_datapath_id", include_self=True)
+        switch_datapath_id = subscriber_si.get_westbound_service_instance_properties(
+            "switch_datapath_id", include_self=True)
         source_port = subscriber_si.get_westbound_service_instance_properties("switch_port", include_self=True)
 
         if (s_tag is None):
@@ -108,4 +110,5 @@
 
         return (s_tag, switch_datapath_id, source_port)
 
+
 register_convenience_wrapper("FabricCrossconnectService", ORMWrapperFabricCrossconnectService)
diff --git a/xos/synchronizer/models/models.py b/xos/synchronizer/models/models.py
index 8c75a2e..13b56ed 100644
--- a/xos/synchronizer/models/models.py
+++ b/xos/synchronizer/models/models.py
@@ -16,14 +16,17 @@
 
 from models_decl import FabricCrossconnectService_decl, FabricCrossconnectServiceInstance_decl, BNGPortMapping_decl
 
+
 class FabricCrossconnectService(FabricCrossconnectService_decl):
     class Meta:
         proxy = True
 
+
 class FabricCrossconnectServiceInstance(FabricCrossconnectServiceInstance_decl):
-   class Meta:
+    class Meta:
         proxy = True
 
+
 class BNGPortMapping(BNGPortMapping_decl):
     class Meta:
         proxy = True
@@ -38,7 +41,7 @@
                     int(last.strip())
                 except ValueError:
                     raise XOSValidationError("Malformed range %s" % pattern)
-            elif this_range.lower()=="any":
+            elif this_range.lower() == "any":
                 pass
             else:
                 try:
@@ -50,4 +53,3 @@
         self.validate_range(self.s_tag)
 
         super(BNGPortMapping, self).save(*args, **kwargs)
-
diff --git a/xos/synchronizer/models/test_models.py b/xos/synchronizer/models/test_models.py
index 47b1bb2..25f83ed 100755
--- a/xos/synchronizer/models/test_models.py
+++ b/xos/synchronizer/models/test_models.py
@@ -13,20 +13,25 @@
 # limitations under the License.
 
 import unittest
-import os, sys
+import os
+import sys
 from mock import patch, Mock, MagicMock
 
-test_path=os.path.abspath(os.path.dirname(os.path.realpath(__file__)))
+test_path = os.path.abspath(os.path.dirname(os.path.realpath(__file__)))
 
 # mocking XOS exception, as they're based in Django
+
+
 class Exceptions:
     XOSValidationError = Exception
     XOSProgrammingError = Exception
     XOSPermissionDenied = Exception
 
+
 class XOS:
     exceptions = Exceptions
 
+
 class TestFabricCrossconnectModels(unittest.TestCase):
     def setUp(self):
 
@@ -40,7 +45,6 @@
         self.models_decl.BNGPortMapping_decl.objects = Mock()
         self.models_decl.BNGPortMapping_decl.objects.filter.return_value = []
 
-
         modules = {
             'xos': MagicMock(),
             'xos.exceptions': self.xos.exceptions,
@@ -115,5 +119,6 @@
 
         self.assertEqual(e.exception.message, 'Malformed range 123,')
 
+
 if __name__ == '__main__':
     unittest.main()
diff --git a/xos/synchronizer/steps/__init__.py b/xos/synchronizer/steps/__init__.py
new file mode 100644
index 0000000..19d1424
--- /dev/null
+++ b/xos/synchronizer/steps/__init__.py
@@ -0,0 +1,13 @@
+# Copyright 2019-present Open Networking Foundation
+#
+# 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.
diff --git a/xos/synchronizer/steps/sync_fabric_crossconnect_service_instance.py b/xos/synchronizer/steps/sync_fabric_crossconnect_service_instance.py
index 2481af8..5814c19 100644
--- a/xos/synchronizer/steps/sync_fabric_crossconnect_service_instance.py
+++ b/xos/synchronizer/steps/sync_fabric_crossconnect_service_instance.py
@@ -13,11 +13,13 @@
 # limitations under the License.
 
 from xossynchronizer.steps.syncstep import SyncStep, DeferredException
-from xossynchronizer.modelaccessor import model_accessor, FabricCrossconnectServiceInstance, ServiceInstance, BNGPortMapping
+from xossynchronizer.modelaccessor import model_accessor, \
+    FabricCrossconnectServiceInstance, \
+    ServiceInstance, \
+    BNGPortMapping
 
 from xosconfig import Config
 from multistructlog import create_logger
-import urllib
 import requests
 from requests.auth import HTTPBasicAuth
 
@@ -50,10 +52,12 @@
         fabric_onos = fabric_onos[0]
 
         return {
-            'url': SyncFabricCrossconnectServiceInstance.format_url("%s:%s" % (fabric_onos.rest_hostname, fabric_onos.rest_port)),
+            'url': SyncFabricCrossconnectServiceInstance.format_url(
+                "%s:%s" %
+                (fabric_onos.rest_hostname,
+                 fabric_onos.rest_port)),
             'user': fabric_onos.rest_username,
-            'pass': fabric_onos.rest_password
-        }
+            'pass': fabric_onos.rest_password}
 
     def make_handle(self, s_tag, switch_datapath_id):
         # Generate a backend_handle that uniquely identifies the cross connect. ONOS doesn't provide us a handle, so
@@ -62,24 +66,24 @@
         return "%d/%s" % (s_tag, switch_datapath_id)
 
     def extract_handle(self, backend_handle):
-        (s_tag, switch_datapath_id) = backend_handle.split("/",1)
+        (s_tag, switch_datapath_id) = backend_handle.split("/", 1)
         s_tag = int(s_tag)
         return (s_tag, switch_datapath_id)
 
     def range_matches(self, value, pattern):
-        value=int(value)
+        value = int(value)
         for this_range in pattern.split(","):
             this_range = this_range.strip()
             if "-" in this_range:
                 (first, last) = this_range.split("-")
                 first = int(first.strip())
                 last = int(last.strip())
-                if (value>=first) and (value<=last):
+                if (value >= first) and (value <= last):
                     return True
-            elif this_range.lower()=="any":
+            elif this_range.lower() == "any":
                 return True
             else:
-                if (value==int(this_range)):
+                if (value == int(this_range)):
                     return True
         return False
 
@@ -95,7 +99,7 @@
         # See if there are any ranges or "any" that match
         for bng_mapping in BNGPortMapping.objects.all():
             if self.range_matches(s_tag, bng_mapping.s_tag):
-                 return bng_mapping
+                return bng_mapping
 
         return None
 
@@ -107,7 +111,7 @@
 
         onos = self.get_fabric_onos_info(o)
 
-        si = ServiceInstance.objects.get(id=o.id)
+        ServiceInstance.objects.get(id=o.id)
 
         if (o.s_tag is None):
             raise Exception("Cannot sync FabricCrossconnectServiceInstance if s_tag is None on fcsi %s" % o.id)
@@ -116,16 +120,18 @@
             raise Exception("Cannot sync FabricCrossconnectServiceInstance if source_port is None on fcsi %s" % o.id)
 
         if (not o.switch_datapath_id):
-            raise Exception("Cannot sync FabricCrossconnectServiceInstance if switch_datapath_id is unset on fcsi %s" % o.id)
+            raise Exception(
+                "Cannot sync FabricCrossconnectServiceInstance if switch_datapath_id is unset on fcsi %s" %
+                o.id)
 
-        bng_mapping = self.find_bng(s_tag = o.s_tag)
+        bng_mapping = self.find_bng(s_tag=o.s_tag)
         if not bng_mapping:
             raise Exception("Unable to determine BNG port for s_tag %s" % o.s_tag)
         east_port = bng_mapping.switch_port
 
-        data = { "deviceId": o.switch_datapath_id,
-                 "vlanId": o.s_tag,
-                 "ports": [ int(o.source_port), int(east_port) ] }
+        data = {"deviceId": o.switch_datapath_id,
+                "vlanId": o.s_tag,
+                "ports": [int(o.source_port), int(east_port)]}
 
         url = onos['url'] + '/onos/segmentrouting/xconnect'
 
@@ -155,8 +161,8 @@
             # backend_handle has everything we need in it to delete this entry.
             (s_tag, switch_datapath_id) = self.extract_handle(o.backend_handle)
 
-            data = { "deviceId": switch_datapath_id,
-                     "vlanId": s_tag }
+            data = {"deviceId": switch_datapath_id,
+                    "vlanId": s_tag}
 
             url = onos['url'] + '/onos/segmentrouting/xconnect'
 
diff --git a/xos/synchronizer/steps/test_sync_fabric_crossconnect_service_instance.py b/xos/synchronizer/steps/test_sync_fabric_crossconnect_service_instance.py
index 62c8d5b..44f3b91 100644
--- a/xos/synchronizer/steps/test_sync_fabric_crossconnect_service_instance.py
+++ b/xos/synchronizer/steps/test_sync_fabric_crossconnect_service_instance.py
@@ -15,24 +15,26 @@
 import unittest
 
 import functools
-from mock import patch, call, Mock, PropertyMock, MagicMock
+from mock import patch, Mock
 import requests_mock
-import multistructlog
-from multistructlog import create_logger
 
-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__)))
+
 
 def mock_get_westbound_service_instance_properties(props, prop):
     return props[prop]
 
+
 def match_json(desired, req):
-    if desired!=req.json():
+    if desired != req.json():
         raise Exception("Got request %s, but body is not matching" % req.url)
         return False
     return True
 
+
 class TestSyncFabricCrossconnectServiceInstance(unittest.TestCase):
 
     def setUp(self):
@@ -48,11 +50,11 @@
         # END Setting up the config module
 
         from xossynchronizer.mock_modelaccessor_build import mock_modelaccessor_config
-        mock_modelaccessor_config(test_path, [("fabric-crossconnect", "fabric-crossconnect.xproto"),])
+        mock_modelaccessor_config(test_path, [("fabric-crossconnect", "fabric-crossconnect.xproto"), ])
 
         import xossynchronizer.modelaccessor
         import mock_modelaccessor
-        reload(mock_modelaccessor) # in case nose2 loaded it in a previous test
+        reload(mock_modelaccessor)  # in case nose2 loaded it in a previous test
         reload(xossynchronizer.modelaccessor)      # in case nose2 loaded it in a previous test
 
         from xossynchronizer.modelaccessor import model_accessor
@@ -69,14 +71,14 @@
         self.sync_step.log = Mock()
 
         # mock onos-fabric
-        self.onos_fabric = Service(name = "onos-fabric",
-                              rest_hostname = "onos-fabric",
-                              rest_port = "8181",
-                              rest_username = "onos",
-                              rest_password = "rocks")
+        self.onos_fabric = Service(name="onos-fabric",
+                                   rest_hostname="onos-fabric",
+                                   rest_port="8181",
+                                   rest_username="onos",
+                                   rest_password="rocks")
 
-        self.service = FabricCrossconnectService(name = "fcservice",
-                                                 provider_services = [self.onos_fabric])
+        self.service = FabricCrossconnectService(name="fcservice",
+                                                 provider_services=[self.onos_fabric])
 
     def mock_westbound(self, fsi, s_tag, switch_datapath_id, switch_port):
         # Mock out a ServiceInstance so the syncstep can call get_westbound_service_instance_properties on it
@@ -163,8 +165,8 @@
     @requests_mock.Mocker()
     def test_sync(self, m):
         with patch.object(ServiceInstance.objects, "get_items") as serviceinstance_objects, \
-            patch.object(BNGPortMapping.objects, "get_items") as bng_objects, \
-            patch.object(FabricCrossconnectServiceInstance, "save") as fcsi_save:
+                patch.object(BNGPortMapping.objects, "get_items") as bng_objects, \
+                patch.object(FabricCrossconnectServiceInstance, "save") as fcsi_save:
 
             fsi = FabricCrossconnectServiceInstance(id=7777, owner=self.service, s_tag=111, source_port=3,
                                                     switch_datapath_id="of:0000000000000201", updated=1, policed=2)
@@ -175,8 +177,8 @@
             bng_objects.return_value = [bngmapping]
 
             desired_data = {"deviceId": "of:0000000000000201",
-                    "vlanId": 111,
-                    "ports": [3, 4]}
+                            "vlanId": 111,
+                            "ports": [3, 4]}
 
             m.post("http://onos-fabric:8181/onos/segmentrouting/xconnect",
                    status_code=200,
@@ -189,8 +191,7 @@
             fcsi_save.assert_called()
 
     def test_sync_no_bng_mapping(self):
-        with patch.object(ServiceInstance.objects, "get_items") as serviceinstance_objects, \
-            patch.object(FabricCrossconnectServiceInstance, "save") as fcsi_save:
+        with patch.object(ServiceInstance.objects, "get_items") as serviceinstance_objects:
 
             fsi = FabricCrossconnectServiceInstance(id=7777, owner=self.service, s_tag=111, source_port=3,
                                                     switch_datapath_id="of:0000000000000201", updated=1, policed=2)
@@ -203,8 +204,7 @@
             self.assertEqual(e.exception.message, "Unable to determine BNG port for s_tag 111")
 
     def test_sync_not_policed(self):
-        with patch.object(ServiceInstance.objects, "get_items") as serviceinstance_objects, \
-            patch.object(FabricCrossconnectServiceInstance, "save") as fcsi_save:
+        with patch.object(ServiceInstance.objects, "get_items") as serviceinstance_objects:
 
             fsi = FabricCrossconnectServiceInstance(id=7777, owner=self.service, source_port=3,
                                                     switch_datapath_id="of:0000000000000201", updated=1, policed=0)
@@ -217,8 +217,7 @@
             self.assertEqual(e.exception.message, "Waiting for model_policy to run on fcsi 7777")
 
     def test_sync_no_s_tag(self):
-        with patch.object(ServiceInstance.objects, "get_items") as serviceinstance_objects, \
-            patch.object(FabricCrossconnectServiceInstance, "save") as fcsi_save:
+        with patch.object(ServiceInstance.objects, "get_items") as serviceinstance_objects:
 
             fsi = FabricCrossconnectServiceInstance(id=7777, owner=self.service, source_port=3,
                                                     switch_datapath_id="of:0000000000000201", updated=1, policed=2)
@@ -228,11 +227,11 @@
             with self.assertRaises(Exception) as e:
                 self.sync_step(model_accessor=self.model_accessor).sync_record(fsi)
 
-            self.assertEqual(e.exception.message, "Cannot sync FabricCrossconnectServiceInstance if s_tag is None on fcsi 7777")
+            self.assertEqual(e.exception.message,
+                             "Cannot sync FabricCrossconnectServiceInstance if s_tag is None on fcsi 7777")
 
     def test_sync_no_switch_datapath_id(self):
-        with patch.object(ServiceInstance.objects, "get_items") as serviceinstance_objects, \
-            patch.object(FabricCrossconnectServiceInstance, "save") as fcsi_save:
+        with patch.object(ServiceInstance.objects, "get_items") as serviceinstance_objects:
 
             fsi = FabricCrossconnectServiceInstance(id=7777, owner=self.service, source_port=3, s_tag=111,
                                                     updated=1, policed=2)
@@ -242,11 +241,12 @@
             with self.assertRaises(Exception) as e:
                 self.sync_step(model_accessor=self.model_accessor).sync_record(fsi)
 
-            self.assertEqual(e.exception.message, "Cannot sync FabricCrossconnectServiceInstance if switch_datapath_id is unset on fcsi 7777")
+            self.assertEqual(
+                e.exception.message,
+                "Cannot sync FabricCrossconnectServiceInstance if switch_datapath_id is unset on fcsi 7777")
 
     def test_sync_no_source_port(self):
-        with patch.object(ServiceInstance.objects, "get_items") as serviceinstance_objects, \
-            patch.object(FabricCrossconnectServiceInstance, "save") as fcsi_save:
+        with patch.object(ServiceInstance.objects, "get_items") as serviceinstance_objects:
 
             fsi = FabricCrossconnectServiceInstance(id=7777, owner=self.service, s_tag=111,
                                                     switch_datapath_id="of:0000000000000201", updated=1, policed=2)
@@ -256,24 +256,24 @@
             with self.assertRaises(Exception) as e:
                 self.sync_step(model_accessor=self.model_accessor).sync_record(fsi)
 
-            self.assertEqual(e.exception.message, "Cannot sync FabricCrossconnectServiceInstance if source_port is None on fcsi 7777")
+            self.assertEqual(e.exception.message,
+                             "Cannot sync FabricCrossconnectServiceInstance if source_port is None on fcsi 7777")
 
     @requests_mock.Mocker()
     def test_delete(self, m):
-        with patch.object(FabricCrossconnectServiceInstance.objects, "get_items") as fcsi_objects, \
-                patch.object(FabricCrossconnectServiceInstance, "save") as fcsi_save:
+        with patch.object(FabricCrossconnectServiceInstance.objects, "get_items") as fcsi_objects:
             fsi = FabricCrossconnectServiceInstance(id=7777, owner=self.service,
                                                     backend_handle="111/of:0000000000000201",
                                                     enacted=True)
 
-            fcsi_objects.return_value=[fsi]
+            fcsi_objects.return_value = [fsi]
 
             desired_data = {"deviceId": "of:0000000000000201",
                             "vlanId": 111}
 
             m.delete("http://onos-fabric:8181/onos/segmentrouting/xconnect",
-                   status_code=204,
-                   additional_matcher=functools.partial(match_json, desired_data))
+                     status_code=204,
+                     additional_matcher=functools.partial(match_json, desired_data))
 
             self.sync_step(model_accessor=self.model_accessor).delete_record(fsi)
             self.assertTrue(m.called)
@@ -282,5 +282,6 @@
         self.o = None
         sys.path = self.sys_path_save
 
+
 if __name__ == '__main__':
     unittest.main()
diff --git a/xos/unittest.cfg b/xos/unittest.cfg
deleted file mode 100644
index 07b76f7..0000000
--- a/xos/unittest.cfg
+++ /dev/null
@@ -1,13 +0,0 @@
-[unittest]
-plugins=nose2.plugins.junitxml
-code-directories=synchronizer
-                 model_policies
-                 steps
-                 models
-                 event_steps
-
-[coverage]
-always-on = True
-coverage = synchronizer
-coverage-report = term
-coverage-report = html
\ No newline at end of file