SEBA-497 delayering, Makefile, and tox for att-workflow-drvier

Change-Id: I5869c36b8b716cab02ae12a343969c4feeacf5fb
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/auth_event.py b/xos/synchronizer/event_steps/auth_event.py
index 2d9f4d7..b7124a9 100644
--- a/xos/synchronizer/event_steps/auth_event.py
+++ b/xos/synchronizer/event_steps/auth_event.py
@@ -14,12 +14,10 @@
 # limitations under the License.
 
 import json
-import time
-import os
-import sys
 from xossynchronizer.event_steps.eventstep import EventStep
 from helpers import AttHelpers
 
+
 class SubscriberAuthEventStep(EventStep):
     topics = ["authentication.events"]
     technology = "kafka"
@@ -33,10 +31,12 @@
         onu_sn = AttHelpers.get_onu_sn(self.model_accessor, self.log, value)
         si = AttHelpers.get_si_by_sn(self.model_accessor, self.log, onu_sn)
         if not si:
-            self.log.exception("authentication.events: Cannot find att-workflow-driver service instance for this event", kafka_event=value)
+            self.log.exception(
+                "authentication.events: Cannot find att-workflow-driver service instance for this event",
+                kafka_event=value)
             raise Exception("authentication.events: Cannot find att-workflow-driver service instance for this event")
 
         self.log.info("authentication.events: Got event for subscriber", event_value=value, onu_sn=onu_sn, si=si)
 
-        si.authentication_state = value["authenticationState"];
+        si.authentication_state = value["authenticationState"]
         si.save_changed_fields(always_update_timestamp=True)
diff --git a/xos/synchronizer/event_steps/dhcp_event.py b/xos/synchronizer/event_steps/dhcp_event.py
index ab411f7..06abc5a 100644
--- a/xos/synchronizer/event_steps/dhcp_event.py
+++ b/xos/synchronizer/event_steps/dhcp_event.py
@@ -14,12 +14,10 @@
 # limitations under the License.
 
 import json
-import time
-import os
-import sys
 from xossynchronizer.event_steps.eventstep import EventStep
 from helpers import AttHelpers
 
+
 class SubscriberDhcpEventStep(EventStep):
     topics = ["dhcp.events"]
     technology = "kafka"
@@ -34,7 +32,9 @@
         si = AttHelpers.get_si_by_sn(self.model_accessor, self.log, onu_sn)
 
         if not si:
-            self.log.exception("dhcp.events: Cannot find att-workflow-driver service instance for this event", kafka_event=value)
+            self.log.exception(
+                "dhcp.events: Cannot find att-workflow-driver service instance for this event",
+                kafka_event=value)
             raise Exception("dhcp.events: Cannot find att-workflow-driver service instance for this event")
 
         self.log.info("dhcp.events: Got event for subscriber", event_value=value, onu_sn=onu_sn, si=si)
diff --git a/xos/synchronizer/event_steps/onu_event.py b/xos/synchronizer/event_steps/onu_event.py
index bae496d..0db61df 100644
--- a/xos/synchronizer/event_steps/onu_event.py
+++ b/xos/synchronizer/event_steps/onu_event.py
@@ -17,6 +17,7 @@
 import json
 from xossynchronizer.event_steps.eventstep import EventStep
 
+
 class ONUEventStep(EventStep):
     topics = ["onu.events"]
     technology = "kafka"
@@ -28,18 +29,21 @@
 
     def get_att_si(self, event):
         try:
-            att_si = self.model_accessor.AttWorkflowDriverServiceInstance.objects.get(serial_number=event["serial_number"])
-            att_si.no_sync = False;
+            att_si = self.model_accessor.AttWorkflowDriverServiceInstance.objects.get(
+                serial_number=event["serial_number"])
+            att_si.no_sync = False
             att_si.uni_port_id = event["uni_port_id"]
             att_si.of_dpid = event["of_dpid"]
             self.log.debug("onu.events: Found existing AttWorkflowDriverServiceInstance", si=att_si)
         except IndexError:
-            # create an AttWorkflowDriverServiceInstance, the validation will be triggered in the corresponding sync step
+            # create an AttWorkflowDriverServiceInstance, the validation will be
+            # triggered in the corresponding sync step
             att_si = self.model_accessor.AttWorkflowDriverServiceInstance(
                 serial_number=event["serial_number"],
                 of_dpid=event["of_dpid"],
                 uni_port_id=event["uni_port_id"],
-                owner=self.model_accessor.AttWorkflowDriverService.objects.first() # we assume there is only one AttWorkflowDriverService
+                # we assume there is only one AttWorkflowDriverService
+                owner=self.model_accessor.AttWorkflowDriverService.objects.first()
             )
             self.log.debug("onu.events: Created new AttWorkflowDriverServiceInstance", si=att_si)
         return att_si
diff --git a/xos/synchronizer/event_steps/test_auth_event.py b/xos/synchronizer/event_steps/test_auth_event.py
index 35f8350..e875c43 100644
--- a/xos/synchronizer/event_steps/test_auth_event.py
+++ b/xos/synchronizer/event_steps/test_auth_event.py
@@ -13,12 +13,14 @@
 # limitations under the License.
 
 import unittest
-from mock import patch, call, Mock, PropertyMock
+from mock import patch, Mock
 import json
 
-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 TestSubscriberAuthEvent(unittest.TestCase):
 
@@ -42,7 +44,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
@@ -67,7 +69,6 @@
         self.hippie_si.serial_number = "BRCM1234"
         self.hippie_si.save = Mock()
 
-
     def tearDown(self):
         sys.path = self.sys_path_save
 
@@ -80,8 +81,8 @@
         })
 
         with patch.object(VOLTService.objects, "get_items") as volt_service_mock, \
-            patch.object(AttWorkflowDriverServiceInstance.objects, "get_items") as hippie_si_mock, \
-            patch.object(self.volt, "get_onu_sn_from_openflow") as get_onu_sn:
+                patch.object(AttWorkflowDriverServiceInstance.objects, "get_items") as hippie_si_mock, \
+                patch.object(self.volt, "get_onu_sn_from_openflow") as get_onu_sn:
 
             volt_service_mock.return_value = [self.volt]
             get_onu_sn.return_value = "BRCM1234"
@@ -89,9 +90,12 @@
 
             self.event_step.process_event(self.event)
 
-            self.hippie_si.save.assert_called_with(always_update_timestamp=True, update_fields=['authentication_state', 'serial_number', 'updated'])
+            self.hippie_si.save.assert_called_with(
+                always_update_timestamp=True, update_fields=[
+                    'authentication_state', 'serial_number', 'updated'])
             self.assertEqual(self.hippie_si.authentication_state, 'APPROVED')
 
+
 if __name__ == '__main__':
-    sys.path.append("..") # for import of helpers.py
-    unittest.main()
\ No newline at end of file
+    sys.path.append("..")  # for import of helpers.py
+    unittest.main()
diff --git a/xos/synchronizer/event_steps/test_dhcp_event.py b/xos/synchronizer/event_steps/test_dhcp_event.py
index 62fcaee..7176ba9 100644
--- a/xos/synchronizer/event_steps/test_dhcp_event.py
+++ b/xos/synchronizer/event_steps/test_dhcp_event.py
@@ -13,12 +13,14 @@
 # limitations under the License.
 
 import unittest
-from mock import patch, call, Mock, PropertyMock
+from mock import patch, Mock
 import json
 
-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 TestSubscriberAuthEvent(unittest.TestCase):
 
@@ -42,7 +44,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
@@ -74,23 +76,22 @@
         self.si.serial_number = "BRCM1234"
         self.si.save = Mock()
 
-
     def tearDown(self):
         sys.path = self.sys_path_save
 
     def test_dhcp_subscriber(self):
 
         self.event.value = json.dumps({
-            "deviceId" : "of:0000000000000001",
-            "portNumber" : "1",
-            "macAddress" : self.mac_address,
-            "ipAddress" : self.ip_address,
+            "deviceId": "of:0000000000000001",
+            "portNumber": "1",
+            "macAddress": self.mac_address,
+            "ipAddress": self.ip_address,
             "messageType": "DHCPREQUEST"
         })
 
         with patch.object(VOLTService.objects, "get_items") as volt_service_mock, \
-            patch.object(AttWorkflowDriverServiceInstance.objects, "get_items") as si_mock, \
-            patch.object(self.volt, "get_onu_sn_from_openflow") as get_onu_sn:
+                patch.object(AttWorkflowDriverServiceInstance.objects, "get_items") as si_mock, \
+                patch.object(self.volt, "get_onu_sn_from_openflow") as get_onu_sn:
 
             self.assertTrue(VOLTService.objects.first() is not None)
 
@@ -105,6 +106,7 @@
             self.assertEqual(self.si.mac_address, self.mac_address)
             self.assertEqual(self.si.ip_address, self.ip_address)
 
+
 if __name__ == '__main__':
-    sys.path.append("..") # for import of helpers.py
-    unittest.main()
\ No newline at end of file
+    sys.path.append("..")  # for import of helpers.py
+    unittest.main()
diff --git a/xos/synchronizer/event_steps/test_onu_events.py b/xos/synchronizer/event_steps/test_onu_events.py
index 4e939b8..4543357 100644
--- a/xos/synchronizer/event_steps/test_onu_events.py
+++ b/xos/synchronizer/event_steps/test_onu_events.py
@@ -13,12 +13,14 @@
 # limitations under the License.
 
 import unittest
-from mock import patch, call, Mock, PropertyMock
+from mock import patch, Mock
 import json
 
-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 TestSyncOLTDevice(unittest.TestCase):
 
@@ -40,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
@@ -69,12 +71,11 @@
     def tearDown(self):
         sys.path = self.sys_path_save
 
-
     def test_create_instance(self):
 
-        with patch.object(AttWorkflowDriverServiceInstance.objects, "get_items") as att_si_mock , \
-            patch.object(AttWorkflowDriverService.objects, "get_items") as service_mock, \
-            patch.object(AttWorkflowDriverServiceInstance, "save", autospec=True) as mock_save:
+        with patch.object(AttWorkflowDriverServiceInstance.objects, "get_items") as att_si_mock, \
+                patch.object(AttWorkflowDriverService.objects, "get_items") as service_mock, \
+                patch.object(AttWorkflowDriverServiceInstance, "save", autospec=True) as mock_save:
 
             att_si_mock.return_value = []
             service_mock.return_value = [self.att]
@@ -98,8 +99,8 @@
             uni_port_id="foo"
         )
 
-        with patch.object(AttWorkflowDriverServiceInstance.objects, "get_items") as att_si_mock , \
-            patch.object(AttWorkflowDriverServiceInstance, "save", autospec=True) as mock_save:
+        with patch.object(AttWorkflowDriverServiceInstance.objects, "get_items") as att_si_mock, \
+                patch.object(AttWorkflowDriverServiceInstance, "save", autospec=True) as mock_save:
 
             att_si_mock.return_value = [si]
 
@@ -128,8 +129,8 @@
             self.event_step.process_event(self.event)
 
             self.assertEqual(mock_save.call_count, 0)
-            
+
 
 if __name__ == '__main__':
     sys.path.append("..")  # for import of helpers.py
-    unittest.main()
\ No newline at end of file
+    unittest.main()