SEBA-497 delayering, Makefile, and tox for onos-synchronizer
Change-Id: I849b307330a6fd5a5de5489d8f2db804a02acead
diff --git a/xos/synchronizer/steps/test_sync_onos_service.py b/xos/synchronizer/steps/test_sync_onos_service.py
index ee6daaf..054baea 100644
--- a/xos/synchronizer/steps/test_sync_onos_service.py
+++ b/xos/synchronizer/steps/test_sync_onos_service.py
@@ -15,20 +15,22 @@
import unittest
import json
import functools
-from mock import patch, call, Mock, PropertyMock
+from mock import patch, Mock
import requests_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 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 TestSyncOnosService(unittest.TestCase):
def setUp(self):
@@ -43,11 +45,11 @@
# END Setting up the config module
from xossynchronizer.mock_modelaccessor_build import mock_modelaccessor_config
- mock_modelaccessor_config(test_path, [("onos-service", "onos.xproto"),])
+ mock_modelaccessor_config(test_path, [("onos-service", "onos.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 sync_onos_service import SyncONOSService, model_accessor
@@ -58,7 +60,6 @@
for (k, v) in model_accessor.all_model_classes.items():
globals()[k] = v
-
self.sync_step = SyncONOSService
self.onos = Mock(spec=[
@@ -162,14 +163,16 @@
additional_matcher=functools.partial(match_json, json.loads(expected_conf)))
with self.assertRaises(Exception) as e, \
- patch.object(Service.objects, "get_items") as service_mock:
+ patch.object(Service.objects, "get_items") as service_mock:
service_mock.return_value = [self.service]
self.sync_step(model_accessor=self.model_accessor).sync_record(self.onos)
self.assertTrue(m.called)
self.assertEqual(m.call_count, 1)
- self.assertEqual(e.exception.message, "Failed to add config http://onos-url:8181/onos/v1/network/configuration/apps/org.onosproject.olt in ONOS")
+ self.assertEqual(
+ e.exception.message,
+ "Failed to add config http://onos-url:8181/onos/v1/network/configuration/apps/org.onosproject.olt in ONOS")
@requests_mock.Mocker()
def test_delete(self, m):
@@ -180,5 +183,6 @@
self.assertTrue(m.called)
self.assertEqual(m.call_count, 1)
+
if __name__ == '__main__':
unittest.main()