SEBA-198 Fix ONOS synchronizer failing when dependencies set to None
Change-Id: I7228abca290d2f9032365a2d560cddab9e41a349
diff --git a/xos/synchronizer/steps/sync_onos_app.py b/xos/synchronizer/steps/sync_onos_app.py
index cc30645..82e24e3 100644
--- a/xos/synchronizer/steps/sync_onos_app.py
+++ b/xos/synchronizer/steps/sync_onos_app.py
@@ -41,7 +41,9 @@
:param deps: comma separated list of application names
:return: bool
"""
- for dep in [x.strip() for x in str(deps).split(',') if x is not ""]:
+ if not deps:
+ return True
+ for dep in [x.strip() for x in deps.split(',') if x is not ""]:
try:
app = ONOSApp.objects.get(app_id=dep)
if not app.backend_code == 1:
diff --git a/xos/synchronizer/steps/test_sync_onos_app.py b/xos/synchronizer/steps/test_sync_onos_app.py
index bd63b99..ffde435 100644
--- a/xos/synchronizer/steps/test_sync_onos_app.py
+++ b/xos/synchronizer/steps/test_sync_onos_app.py
@@ -160,6 +160,30 @@
self.assertFalse(m.called)
@requests_mock.Mocker()
+ def test_dependencies_none(self, m):
+ """ App should sync if dependencies is set to None """
+
+ self.onos_app.dependencies = None
+
+ m.post("http://onos-url:8181/onos/v1/applications/org.onosproject.vrouter/active",
+ status_code=200,
+ additional_matcher=match_none)
+
+ m.get("http://onos-url:8181/onos/v1/applications/org.onosproject.vrouter",
+ status_code=200,
+ json=self.vrouter_app_response)
+
+ self.si.serviceinstanceattribute_dict = {}
+
+ with patch.object(ServiceInstance.objects, "get_items") as mock_si:
+ mock_si.return_value = [self.si]
+ self.sync_step().sync_record(self.onos_app)
+
+ self.assertTrue(m.called)
+ self.assertEqual(m.call_count, 2)
+ self.assertEqual(self.onos_app.version, self.vrouter_app_response["version"])
+
+ @requests_mock.Mocker()
def test_app_sync_local_app_no_config(self, m):
"""
Activate an application that is already installed in ONOS