Fixing SI creation

Change-Id: I7b60169fd2e4f39f8bc1a74c8db1df0e90f69a0e
diff --git a/xos/synchronizer/event_steps/onu_event.py b/xos/synchronizer/event_steps/onu_event.py
index 5dc879f..f21231c 100644
--- a/xos/synchronizer/event_steps/onu_event.py
+++ b/xos/synchronizer/event_steps/onu_event.py
@@ -19,7 +19,7 @@
 import os
 import sys
 from synchronizers.new_base.eventstep import EventStep
-from synchronizers.new_base.modelaccessor import AttWorkflowDriverServiceInstance, model_accessor
+from synchronizers.new_base.modelaccessor import AttWorkflowDriverService, AttWorkflowDriverServiceInstance, model_accessor
 
 class ONUEventStep(EventStep):
     topics = ["onu.events"]
@@ -42,7 +42,8 @@
             att_si = AttWorkflowDriverServiceInstance(
                 serial_number=event["serial_number"],
                 of_dpid=event["of_dpid"],
-                uni_port_id=event["uni_port_id"]
+                uni_port_id=event["uni_port_id"],
+                owner=AttWorkflowDriverService.objects.first() # we assume there is only one AttWorkflowDriverService
             )
             self.log.debug("onu.events: Created new AttWorkflowDriverServiceInstance", si=att_si)
         return att_si
@@ -54,7 +55,7 @@
         att_si = self.get_att_si(value)
         if value["status"] == "activated":
             self.log.info("onu.events: activated onu", value=value)
-            att_si.onu_state = "ACTIVE"
+            att_si.onu_state = "ENABLED"
         elif value["status"] == "disabled":
             self.log.info("onu.events: disabled onu", value=value)
             att_si.onu_state = "DISABLED"
diff --git a/xos/synchronizer/event_steps/test_onu_events.py b/xos/synchronizer/event_steps/test_onu_events.py
index b690663..bea8c0c 100644
--- a/xos/synchronizer/event_steps/test_onu_events.py
+++ b/xos/synchronizer/event_steps/test_onu_events.py
@@ -85,6 +85,8 @@
         }
         self.event.value = json.dumps(self.event_dict)
 
+        self.att = AttWorkflowDriverService(name="att-workflow-driver")
+
     def tearDown(self):
         sys.path = self.sys_path_save
 
@@ -92,9 +94,11 @@
     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:
 
             att_si_mock.return_value = []
+            service_mock.return_value = [self.att]
 
             self.event_step.process_event(self.event)
 
@@ -105,7 +109,7 @@
             self.assertEqual(att_si.serial_number, self.event_dict['serial_number'])
             self.assertEqual(att_si.of_dpid, self.event_dict['of_dpid'])
             self.assertEqual(att_si.uni_port_id, self.event_dict['uni_port_id'])
-            self.assertEqual(att_si.onu_state, "ACTIVE")
+            self.assertEqual(att_si.onu_state, "ENABLED")
 
     def test_reuse_instance(self):
 
@@ -129,7 +133,7 @@
             self.assertEqual(att_si.serial_number, self.event_dict['serial_number'])
             self.assertEqual(att_si.of_dpid, self.event_dict['of_dpid'])
             self.assertEqual(att_si.uni_port_id, self.event_dict['uni_port_id'])
-            self.assertEqual(att_si.onu_state, "ACTIVE")
+            self.assertEqual(att_si.onu_state, "ENABLED")
 
     def test_disable_onu(self):
         self.event_dict = {
@@ -141,9 +145,11 @@
         self.event.value = json.dumps(self.event_dict)
 
         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]
 
             self.event_step.process_event(self.event)