SEBA-405 Update vrouter service to use synchronizer library
Change-Id: I06096ebce6bb88b09c642dd59245cbd1f17cdc2d
diff --git a/xos/synchronizer/steps/test_sync_routes.py b/xos/synchronizer/steps/test_sync_routes.py
index d64272f..2a5ebc1 100644
--- a/xos/synchronizer/steps/test_sync_routes.py
+++ b/xos/synchronizer/steps/test_sync_routes.py
@@ -22,27 +22,7 @@
import os, sys
-# Hack to load synchronizer framework
test_path=os.path.abspath(os.path.dirname(os.path.realpath(__file__)))
-xos_dir=os.path.join(test_path, "../../..")
-if not os.path.exists(os.path.join(test_path, "new_base")):
- xos_dir=os.path.join(test_path, "../../../../../../orchestration/xos/xos")
- services_dir = os.path.join(xos_dir, "../../xos_services")
-sys.path.append(xos_dir)
-sys.path.append(os.path.join(xos_dir, 'synchronizers', 'new_base'))
-# END Hack to load synchronizer framework
-
-# generate model from xproto
-def get_models_fn(service_name, xproto_name):
- name = os.path.join(service_name, "xos", xproto_name)
- if os.path.exists(os.path.join(services_dir, name)):
- return name
- else:
- name = os.path.join(service_name, "xos", "synchronizer", "models", xproto_name)
- if os.path.exists(os.path.join(services_dir, name)):
- return name
- raise Exception("Unable to find service=%s xproto=%s" % (service_name, xproto_name))
-# END generate model from xproto
def match_json(desired, req):
if desired!=req.json():
@@ -55,8 +35,6 @@
def setUp(self):
self.sys_path_save = sys.path
- sys.path.append(xos_dir)
- sys.path.append(os.path.join(xos_dir, 'synchronizers', 'new_base'))
# Setting up the config module
from xosconfig import Config
@@ -65,12 +43,18 @@
Config.init(config, "synchronizer-config-schema.yaml")
# END Setting up the config module
- from synchronizers.new_base.mock_modelaccessor_build import build_mock_modelaccessor
- build_mock_modelaccessor(xos_dir, services_dir, [get_models_fn("vrouter", "vrouter.xproto")])
- import synchronizers.new_base.modelaccessor
+ from xossynchronizer.mock_modelaccessor_build import mock_modelaccessor_config
+ mock_modelaccessor_config(test_path, [("vrouter", "vrouter.xproto")])
+
+ import xossynchronizer.modelaccessor
+ import mock_modelaccessor
+ 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_routes import SyncRoutes, model_accessor
+ self.model_accessor = model_accessor
+
# import all class names to globals
for (k, v) in model_accessor.all_model_classes.items():
globals()[k] = v
@@ -122,7 +106,7 @@
status_code=204,
additional_matcher=functools.partial(match_json, expected_conf))
- self.sync_step().sync_record(self.o)
+ self.sync_step(model_accessor = self.model_accessor).sync_record(self.o)
self.assertTrue(m.called)
@@ -141,7 +125,7 @@
status_code=204,
additional_matcher=functools.partial(match_json, expected_conf))
- self.sync_step().sync_record(self.o)
+ self.sync_step(model_accessor = self.model_accessor).sync_record(self.o)
self.assertTrue(m.called)
@@ -160,7 +144,7 @@
status_code=204,
additional_matcher=functools.partial(match_json, expected_conf))
- self.sync_step().delete_record(self.o)
+ self.sync_step(model_accessor = self.model_accessor).delete_record(self.o)
self.assertTrue(m.called)
@@ -179,6 +163,6 @@
status_code=204,
additional_matcher=functools.partial(match_json, expected_conf))
- self.sync_step().delete_record(self.o)
+ self.sync_step(model_accessor = self.model_accessor).delete_record(self.o)
self.assertTrue(m.called)