CORD-1993 port model_policy test to new framework;
cherry-picked from gerrit 6998 commit d8b1439d9e6e1392546a2c26aaccbdf6f92c7b25

Change-Id: I387bd16c3ae2c863e9a0fb7d5dcdac731779b5b9
diff --git a/lib/xos-genx/xosgenx/targets/mock_classes.xtarget b/lib/xos-genx/xosgenx/targets/mock_classes.xtarget
index 3973568..a28f4c3 100644
--- a/lib/xos-genx/xosgenx/targets/mock_classes.xtarget
+++ b/lib/xos-genx/xosgenx/targets/mock_classes.xtarget
@@ -22,9 +22,9 @@
 
 class Object:
     objects = Mock()
+    save = Mock()
+    delete = Mock()
     def __init__(self, **kwargs):
-        setattr(self, 'save', Mock())
-        setattr(self, 'delete', Mock())
         setattr(self, 'backend_code', 0)
         setattr(self, 'id', 98052)
         setattr(self, 'pk', random.randint(0, 1<<30))
diff --git a/xos/synchronizers/new_base/mock_modelaccessor.py b/xos/synchronizers/new_base/mock_modelaccessor.py
index ef038cc..804c1a1 100644
--- a/xos/synchronizers/new_base/mock_modelaccessor.py
+++ b/xos/synchronizers/new_base/mock_modelaccessor.py
@@ -22,9 +22,9 @@
 
 class Object:
     objects = Mock()
+    save = Mock()
+    delete = Mock()
     def __init__(self, **kwargs):
-        setattr(self, 'save', Mock())
-        setattr(self, 'delete', Mock())
         setattr(self, 'backend_code', 0)
         setattr(self, 'id', 98052)
         setattr(self, 'pk', random.randint(0, 1<<30))
@@ -93,11 +93,12 @@
     lazy_blocked = False
     no_sync = False
     no_policy = False
-    policy_status = "0 - Policy in process"
+    policy_status = "Policy in process"
+    policy_code = 0
     leaf_model_name = None
+    backend_need_delete_policy = False
     
     leaf_model_name = "XOSBase"
-
 class User(Object):
     email = None
     username = "Something"
@@ -129,8 +130,8 @@
     no_sync = False
     no_policy = False
     timezone = "America/New_York"
-    dashboards = None
     policy_status = "0 - Policy in process"
+    leaf_model_name = None
     
     leaf_model_name = "User"
 class Privilege(Object):
@@ -142,13 +143,16 @@
     backend_need_delete = False
     backend_need_reap = False
     backend_status = "Provisioning in progress"
+    backend_code = 0
     deleted = False
     write_protect = False
     lazy_blocked = False
     no_sync = False
     no_policy = False
-    policy_status = "0 - Policy in process"
+    policy_status = "Policy in process"
+    policy_code = 0
     leaf_model_name = None
+    backend_need_delete_policy = False
     accessor_id = None
     accessor_type = None
     controller_id = None
@@ -167,14 +171,17 @@
     backend_register = "{}"
     backend_need_delete = False
     backend_need_reap = False
-    backend_status = "0 - Provisioning in progress"
+    backend_status = "Provisioning in progress"
+    backend_code = 0
     deleted = False
     write_protect = False
     lazy_blocked = False
     no_sync = False
     no_policy = False
-    policy_status = "0 - Policy in process"
+    policy_status = "Policy in process"
+    policy_code = 0
     leaf_model_name = None
+    backend_need_delete_policy = False
     name = None
     addresses = None
     gateway_ip = None
@@ -192,14 +199,17 @@
     backend_register = "{}"
     backend_need_delete = False
     backend_need_reap = False
-    backend_status = "0 - Provisioning in progress"
+    backend_status = "Provisioning in progress"
+    backend_code = 0
     deleted = False
     write_protect = False
     lazy_blocked = False
     no_sync = False
     no_policy = False
-    policy_status = "0 - Policy in process"
+    policy_status = "Policy in process"
+    policy_code = 0
     leaf_model_name = None
+    backend_need_delete_policy = False
     name = None
     backend_type = None
     version = None
@@ -214,28 +224,6 @@
     deployment = None
     
     leaf_model_name = "Controller"
-class ControllerDashboardView(Object):
-    created = None
-    updated = "now()"
-    enacted = None
-    policed = None
-    backend_register = "{}"
-    backend_need_delete = False
-    backend_need_reap = False
-    backend_status = "0 - Provisioning in progress"
-    deleted = False
-    write_protect = False
-    lazy_blocked = False
-    no_sync = False
-    no_policy = False
-    policy_status = "0 - Policy in process"
-    leaf_model_name = None
-    controller = None
-    dashboardView = None
-    enabled = True
-    url = None
-    
-    leaf_model_name = "ControllerDashboardView"
 class ControllerImages(Object):
     created = None
     updated = "now()"
@@ -244,14 +232,17 @@
     backend_register = "{}"
     backend_need_delete = False
     backend_need_reap = False
-    backend_status = "0 - Provisioning in progress"
+    backend_status = "Provisioning in progress"
+    backend_code = 0
     deleted = False
     write_protect = False
     lazy_blocked = False
     no_sync = False
     no_policy = False
-    policy_status = "0 - Policy in process"
+    policy_status = "Policy in process"
+    policy_code = 0
     leaf_model_name = None
+    backend_need_delete_policy = False
     image = None
     controller = None
     glance_image_id = None
@@ -265,14 +256,17 @@
     backend_register = "{}"
     backend_need_delete = False
     backend_need_reap = False
-    backend_status = "0 - Provisioning in progress"
+    backend_status = "Provisioning in progress"
+    backend_code = 0
     deleted = False
     write_protect = False
     lazy_blocked = False
     no_sync = False
     no_policy = False
-    policy_status = "0 - Policy in process"
+    policy_status = "Policy in process"
+    policy_code = 0
     leaf_model_name = None
+    backend_need_delete_policy = False
     network = None
     controller = None
     subnet = None
@@ -293,14 +287,17 @@
     backend_register = "{}"
     backend_need_delete = False
     backend_need_reap = False
-    backend_status = "0 - Provisioning in progress"
+    backend_status = "Provisioning in progress"
+    backend_code = 0
     deleted = False
     write_protect = False
     lazy_blocked = False
     no_sync = False
     no_policy = False
-    policy_status = "0 - Policy in process"
+    policy_status = "Policy in process"
+    policy_code = 0
     leaf_model_name = None
+    backend_need_delete_policy = False
     role = None
     
     leaf_model_name = "ControllerRole"
@@ -312,14 +309,17 @@
     backend_register = "{}"
     backend_need_delete = False
     backend_need_reap = False
-    backend_status = "0 - Provisioning in progress"
+    backend_status = "Provisioning in progress"
+    backend_code = 0
     deleted = False
     write_protect = False
     lazy_blocked = False
     no_sync = False
     no_policy = False
-    policy_status = "0 - Policy in process"
+    policy_status = "Policy in process"
+    policy_code = 0
     leaf_model_name = None
+    backend_need_delete_policy = False
     site = None
     controller = None
     tenant_id = None
@@ -333,14 +333,17 @@
     backend_register = "{}"
     backend_need_delete = False
     backend_need_reap = False
-    backend_status = "0 - Provisioning in progress"
+    backend_status = "Provisioning in progress"
+    backend_code = 0
     deleted = False
     write_protect = False
     lazy_blocked = False
     no_sync = False
     no_policy = False
-    policy_status = "0 - Policy in process"
+    policy_status = "Policy in process"
+    policy_code = 0
     leaf_model_name = None
+    backend_need_delete_policy = False
     controller = None
     privilege = None
     role_id = None
@@ -354,20 +357,22 @@
     backend_register = "{}"
     backend_need_delete = False
     backend_need_reap = False
-    backend_status = "0 - Provisioning in progress"
+    backend_status = "Provisioning in progress"
+    backend_code = 0
     deleted = False
     write_protect = False
     lazy_blocked = False
     no_sync = False
     no_policy = False
-    policy_status = "0 - Policy in process"
+    policy_status = "Policy in process"
+    policy_code = 0
     leaf_model_name = None
+    backend_need_delete_policy = False
     controller = None
     site_privilege = None
     role_id = None
     
     leaf_model_name = "ControllerSitePrivilege"
-
 class ControllerSlice(Object):
     created = None
     updated = "now()"
@@ -376,14 +381,17 @@
     backend_register = "{}"
     backend_need_delete = False
     backend_need_reap = False
-    backend_status = "0 - Provisioning in progress"
+    backend_status = "Provisioning in progress"
+    backend_code = 0
     deleted = False
     write_protect = False
     lazy_blocked = False
     no_sync = False
     no_policy = False
-    policy_status = "0 - Policy in process"
+    policy_status = "Policy in process"
+    policy_code = 0
     leaf_model_name = None
+    backend_need_delete_policy = False
     controller = None
     slice = None
     tenant_id = None
@@ -397,14 +405,17 @@
     backend_register = "{}"
     backend_need_delete = False
     backend_need_reap = False
-    backend_status = "0 - Provisioning in progress"
+    backend_status = "Provisioning in progress"
+    backend_code = 0
     deleted = False
     write_protect = False
     lazy_blocked = False
     no_sync = False
     no_policy = False
-    policy_status = "0 - Policy in process"
+    policy_status = "Policy in process"
+    policy_code = 0
     leaf_model_name = None
+    backend_need_delete_policy = False
     controller = None
     slice_privilege = None
     role_id = None
@@ -418,44 +429,22 @@
     backend_register = "{}"
     backend_need_delete = False
     backend_need_reap = False
-    backend_status = "0 - Provisioning in progress"
+    backend_status = "Provisioning in progress"
+    backend_code = 0
     deleted = False
     write_protect = False
     lazy_blocked = False
     no_sync = False
     no_policy = False
-    policy_status = "0 - Policy in process"
+    policy_status = "Policy in process"
+    policy_code = 0
     leaf_model_name = None
+    backend_need_delete_policy = False
     user = None
     controller = None
     kuser_id = None
     
     leaf_model_name = "ControllerUser"
-class DashboardView(Object):
-    created = None
-    updated = "now()"
-    enacted = None
-    policed = None
-    backend_register = "{}"
-    backend_need_delete = False
-    backend_need_reap = False
-    backend_status = "0 - Provisioning in progress"
-    deleted = False
-    write_protect = False
-    lazy_blocked = False
-    no_sync = False
-    no_policy = False
-    policy_status = "0 - Policy in process"
-    leaf_model_name = None
-    name = None
-    url = None
-    enabled = True
-    icon = "default-icon.png"
-    icon_active = "default-icon-active.png"
-    controllers = None
-    deployments = None
-    
-    leaf_model_name = "DashboardView"
 class Deployment(Object):
     created = None
     updated = "now()"
@@ -464,14 +453,17 @@
     backend_register = "{}"
     backend_need_delete = False
     backend_need_reap = False
-    backend_status = "0 - Provisioning in progress"
+    backend_status = "Provisioning in progress"
+    backend_code = 0
     deleted = False
     write_protect = False
     lazy_blocked = False
     no_sync = False
     no_policy = False
-    policy_status = "0 - Policy in process"
+    policy_status = "Policy in process"
+    policy_code = 0
     leaf_model_name = None
+    backend_need_delete_policy = False
     name = None
     accessControl = "allow all"
     
@@ -484,14 +476,17 @@
     backend_register = "{}"
     backend_need_delete = False
     backend_need_reap = False
-    backend_status = "0 - Provisioning in progress"
+    backend_status = "Provisioning in progress"
+    backend_code = 0
     deleted = False
     write_protect = False
     lazy_blocked = False
     no_sync = False
     no_policy = False
-    policy_status = "0 - Policy in process"
+    policy_status = "Policy in process"
+    policy_code = 0
     leaf_model_name = None
+    backend_need_delete_policy = False
     user = None
     deployment = None
     role = None
@@ -505,14 +500,17 @@
     backend_register = "{}"
     backend_need_delete = False
     backend_need_reap = False
-    backend_status = "0 - Provisioning in progress"
+    backend_status = "Provisioning in progress"
+    backend_code = 0
     deleted = False
     write_protect = False
     lazy_blocked = False
     no_sync = False
     no_policy = False
-    policy_status = "0 - Policy in process"
+    policy_status = "Policy in process"
+    policy_code = 0
     leaf_model_name = None
+    backend_need_delete_policy = False
     role = None
     
     leaf_model_name = "DeploymentRole"
@@ -524,14 +522,17 @@
     backend_register = "{}"
     backend_need_delete = False
     backend_need_reap = False
-    backend_status = "0 - Provisioning in progress"
+    backend_status = "Provisioning in progress"
+    backend_code = 0
     deleted = False
     write_protect = False
     lazy_blocked = False
     no_sync = False
     no_policy = False
-    policy_status = "0 - Policy in process"
+    policy_status = "Policy in process"
+    policy_code = 0
     leaf_model_name = None
+    backend_need_delete_policy = False
     name = None
     
     leaf_model_name = "Diag"
@@ -543,14 +544,17 @@
     backend_register = "{}"
     backend_need_delete = False
     backend_need_reap = False
-    backend_status = "0 - Provisioning in progress"
+    backend_status = "Provisioning in progress"
+    backend_code = 0
     deleted = False
     write_protect = False
     lazy_blocked = False
     no_sync = False
     no_policy = False
-    policy_status = "0 - Policy in process"
+    policy_status = "Policy in process"
+    policy_code = 0
     leaf_model_name = None
+    backend_need_delete_policy = False
     name = None
     description = None
     flavor = None
@@ -564,14 +568,17 @@
     backend_register = "{}"
     backend_need_delete = False
     backend_need_reap = False
-    backend_status = "0 - Provisioning in progress"
+    backend_status = "Provisioning in progress"
+    backend_code = 0
     deleted = False
     write_protect = False
     lazy_blocked = False
     no_sync = False
     no_policy = False
-    policy_status = "0 - Policy in process"
+    policy_status = "Policy in process"
+    policy_code = 0
     leaf_model_name = None
+    backend_need_delete_policy = False
     name = None
     kind = "vm"
     disk_format = None
@@ -588,14 +595,17 @@
     backend_register = "{}"
     backend_need_delete = False
     backend_need_reap = False
-    backend_status = "0 - Provisioning in progress"
+    backend_status = "Provisioning in progress"
+    backend_code = 0
     deleted = False
     write_protect = False
     lazy_blocked = False
     no_sync = False
     no_policy = False
-    policy_status = "0 - Policy in process"
+    policy_status = "Policy in process"
+    policy_code = 0
     leaf_model_name = None
+    backend_need_delete_policy = False
     image = None
     deployment = None
     
@@ -608,14 +618,17 @@
     backend_register = "{}"
     backend_need_delete = False
     backend_need_reap = False
-    backend_status = "0 - Provisioning in progress"
+    backend_status = "Provisioning in progress"
+    backend_code = 0
     deleted = False
     write_protect = False
     lazy_blocked = False
     no_sync = False
     no_policy = False
-    policy_status = "0 - Policy in process"
+    policy_status = "Policy in process"
+    policy_code = 0
     leaf_model_name = None
+    backend_need_delete_policy = False
     instance_id = None
     instance_uuid = None
     name = None
@@ -642,14 +655,17 @@
     backend_register = "{}"
     backend_need_delete = False
     backend_need_reap = False
-    backend_status = "0 - Provisioning in progress"
+    backend_status = "Provisioning in progress"
+    backend_code = 0
     deleted = False
     write_protect = False
     lazy_blocked = False
     no_sync = False
     no_policy = False
-    policy_status = "0 - Policy in process"
+    policy_status = "Policy in process"
+    policy_code = 0
     leaf_model_name = None
+    backend_need_delete_policy = False
     name = None
     template = None
     subnet = None
@@ -673,14 +689,17 @@
     backend_register = "{}"
     backend_need_delete = False
     backend_need_reap = False
-    backend_status = "0 - Provisioning in progress"
+    backend_status = "Provisioning in progress"
+    backend_code = 0
     deleted = False
     write_protect = False
     lazy_blocked = False
     no_sync = False
     no_policy = False
-    policy_status = "0 - Policy in process"
+    policy_status = "Policy in process"
+    policy_code = 0
     leaf_model_name = None
+    backend_need_delete_policy = False
     parameter = None
     value = None
     content_type = None
@@ -695,14 +714,17 @@
     backend_register = "{}"
     backend_need_delete = False
     backend_need_reap = False
-    backend_status = "0 - Provisioning in progress"
+    backend_status = "Provisioning in progress"
+    backend_code = 0
     deleted = False
     write_protect = False
     lazy_blocked = False
     no_sync = False
     no_policy = False
-    policy_status = "0 - Policy in process"
+    policy_status = "Policy in process"
+    policy_code = 0
     leaf_model_name = None
+    backend_need_delete_policy = False
     name = None
     description = None
     
@@ -715,14 +737,17 @@
     backend_register = "{}"
     backend_need_delete = False
     backend_need_reap = False
-    backend_status = "0 - Provisioning in progress"
+    backend_status = "Provisioning in progress"
+    backend_code = 0
     deleted = False
     write_protect = False
     lazy_blocked = False
     no_sync = False
     no_policy = False
-    policy_status = "0 - Policy in process"
+    policy_status = "Policy in process"
+    policy_code = 0
     leaf_model_name = None
+    backend_need_delete_policy = False
     network = None
     slice = None
     
@@ -735,14 +760,17 @@
     backend_register = "{}"
     backend_need_delete = False
     backend_need_reap = False
-    backend_status = "0 - Provisioning in progress"
+    backend_status = "Provisioning in progress"
+    backend_code = 0
     deleted = False
     write_protect = False
     lazy_blocked = False
     no_sync = False
     no_policy = False
-    policy_status = "0 - Policy in process"
+    policy_status = "Policy in process"
+    policy_code = 0
     leaf_model_name = None
+    backend_need_delete_policy = False
     name = None
     description = None
     visibility = "private"
@@ -763,14 +791,17 @@
     backend_register = "{}"
     backend_need_delete = False
     backend_need_reap = False
-    backend_status = "0 - Provisioning in progress"
+    backend_status = "Provisioning in progress"
+    backend_code = 0
     deleted = False
     write_protect = False
     lazy_blocked = False
     no_sync = False
     no_policy = False
-    policy_status = "0 - Policy in process"
+    policy_status = "Policy in process"
+    policy_code = 0
     leaf_model_name = None
+    backend_need_delete_policy = False
     name = None
     site_deployment = None
     
@@ -783,14 +814,17 @@
     backend_register = "{}"
     backend_need_delete = False
     backend_need_reap = False
-    backend_status = "0 - Provisioning in progress"
+    backend_status = "Provisioning in progress"
+    backend_code = 0
     deleted = False
     write_protect = False
     lazy_blocked = False
     no_sync = False
     no_policy = False
-    policy_status = "0 - Policy in process"
+    policy_status = "Policy in process"
+    policy_code = 0
     leaf_model_name = None
+    backend_need_delete_policy = False
     name = None
     node = None
     
@@ -803,14 +837,17 @@
     backend_register = "{}"
     backend_need_delete = False
     backend_need_reap = False
-    backend_status = "0 - Provisioning in progress"
+    backend_status = "Provisioning in progress"
+    backend_code = 0
     deleted = False
     write_protect = False
     lazy_blocked = False
     no_sync = False
     no_policy = False
-    policy_status = "0 - Policy in process"
+    policy_status = "Policy in process"
+    policy_code = 0
     leaf_model_name = None
+    backend_need_delete_policy = False
     network = None
     instance = None
     ip = None
@@ -827,14 +864,17 @@
     backend_register = "{}"
     backend_need_delete = False
     backend_need_reap = False
-    backend_status = "0 - Provisioning in progress"
+    backend_status = "Provisioning in progress"
+    backend_code = 0
     deleted = False
     write_protect = False
     lazy_blocked = False
     no_sync = False
     no_policy = False
-    policy_status = "0 - Policy in process"
+    policy_status = "Policy in process"
+    policy_code = 0
     leaf_model_name = None
+    backend_need_delete_policy = False
     role_type = None
     role = None
     description = None
@@ -848,14 +888,17 @@
     backend_register = "{}"
     backend_need_delete = False
     backend_need_reap = False
-    backend_status = "0 - Provisioning in progress"
+    backend_status = "Provisioning in progress"
+    backend_code = 0
     deleted = False
     write_protect = False
     lazy_blocked = False
     no_sync = False
     no_policy = False
-    policy_status = "0 - Policy in process"
+    policy_status = "Policy in process"
+    policy_code = 0
     leaf_model_name = None
+    backend_need_delete_policy = False
     description = None
     enabled = True
     kind = "generic"
@@ -878,14 +921,17 @@
     backend_register = "{}"
     backend_need_delete = False
     backend_need_reap = False
-    backend_status = "0 - Provisioning in progress"
+    backend_status = "Provisioning in progress"
+    backend_code = 0
     deleted = False
     write_protect = False
     lazy_blocked = False
     no_sync = False
     no_policy = False
-    policy_status = "0 - Policy in process"
+    policy_status = "Policy in process"
+    policy_code = 0
     leaf_model_name = None
+    backend_need_delete_policy = False
     name = None
     value = None
     service = None
@@ -899,14 +945,17 @@
     backend_register = "{}"
     backend_need_delete = False
     backend_need_reap = False
-    backend_status = "0 - Provisioning in progress"
+    backend_status = "Provisioning in progress"
+    backend_code = 0
     deleted = False
     write_protect = False
     lazy_blocked = False
     no_sync = False
     no_policy = False
-    policy_status = "0 - Policy in process"
+    policy_status = "Policy in process"
+    policy_code = 0
     leaf_model_name = None
+    backend_need_delete_policy = False
     provider_service = None
     subscriber_service = None
     connect_method = "none"
@@ -920,14 +969,17 @@
     backend_register = "{}"
     backend_need_delete = False
     backend_need_reap = False
-    backend_status = "0 - Provisioning in progress"
+    backend_status = "Provisioning in progress"
+    backend_code = 0
     deleted = False
     write_protect = False
     lazy_blocked = False
     no_sync = False
     no_policy = False
-    policy_status = "0 - Policy in process"
+    policy_status = "Policy in process"
+    policy_code = 0
     leaf_model_name = None
+    backend_need_delete_policy = False
     name = None
     service = None
     target_uri = None
@@ -941,14 +993,17 @@
     backend_register = "{}"
     backend_need_delete = False
     backend_need_reap = False
-    backend_status = "0 - Provisioning in progress"
+    backend_status = "Provisioning in progress"
+    backend_code = 0
     deleted = False
     write_protect = False
     lazy_blocked = False
     no_sync = False
     no_policy = False
-    policy_status = "0 - Policy in process"
+    policy_status = "Policy in process"
+    policy_code = 0
     leaf_model_name = None
+    backend_need_delete_policy = False
     user = None
     service = None
     role = None
@@ -962,14 +1017,17 @@
     backend_register = "{}"
     backend_need_delete = False
     backend_need_reap = False
-    backend_status = "0 - Provisioning in progress"
+    backend_status = "Provisioning in progress"
+    backend_code = 0
     deleted = False
     write_protect = False
     lazy_blocked = False
     no_sync = False
     no_policy = False
-    policy_status = "0 - Policy in process"
+    policy_status = "Policy in process"
+    policy_code = 0
     leaf_model_name = None
+    backend_need_delete_policy = False
     role = None
     
     leaf_model_name = "ServiceRole"
@@ -981,14 +1039,17 @@
     backend_register = "{}"
     backend_need_delete = False
     backend_need_reap = False
-    backend_status = "0 - Provisioning in progress"
+    backend_status = "Provisioning in progress"
+    backend_code = 0
     deleted = False
     write_protect = False
     lazy_blocked = False
     no_sync = False
     no_policy = False
-    policy_status = "0 - Policy in process"
+    policy_status = "Policy in process"
+    policy_code = 0
     leaf_model_name = None
+    backend_need_delete_policy = False
     name = None
     site_url = None
     enabled = True
@@ -1010,14 +1071,17 @@
     backend_register = "{}"
     backend_need_delete = False
     backend_need_reap = False
-    backend_status = "0 - Provisioning in progress"
+    backend_status = "Provisioning in progress"
+    backend_code = 0
     deleted = False
     write_protect = False
     lazy_blocked = False
     no_sync = False
     no_policy = False
-    policy_status = "0 - Policy in process"
+    policy_status = "Policy in process"
+    policy_code = 0
     leaf_model_name = None
+    backend_need_delete_policy = False
     site = None
     deployment = None
     controller = None
@@ -1032,14 +1096,17 @@
     backend_register = "{}"
     backend_need_delete = False
     backend_need_reap = False
-    backend_status = "0 - Provisioning in progress"
+    backend_status = "Provisioning in progress"
+    backend_code = 0
     deleted = False
     write_protect = False
     lazy_blocked = False
     no_sync = False
     no_policy = False
-    policy_status = "0 - Policy in process"
+    policy_status = "Policy in process"
+    policy_code = 0
     leaf_model_name = None
+    backend_need_delete_policy = False
     user = None
     site = None
     role = None
@@ -1053,14 +1120,17 @@
     backend_register = "{}"
     backend_need_delete = False
     backend_need_reap = False
-    backend_status = "0 - Provisioning in progress"
+    backend_status = "Provisioning in progress"
+    backend_code = 0
     deleted = False
     write_protect = False
     lazy_blocked = False
     no_sync = False
     no_policy = False
-    policy_status = "0 - Policy in process"
+    policy_status = "Policy in process"
+    policy_code = 0
     leaf_model_name = None
+    backend_need_delete_policy = False
     role = None
     
     leaf_model_name = "SiteRole"
@@ -1072,14 +1142,17 @@
     backend_register = "{}"
     backend_need_delete = False
     backend_need_reap = False
-    backend_status = "0 - Provisioning in progress"
+    backend_status = "Provisioning in progress"
+    backend_code = 0
     deleted = False
     write_protect = False
     lazy_blocked = False
     no_sync = False
     no_policy = False
-    policy_status = "0 - Policy in process"
+    policy_status = "Policy in process"
+    policy_code = 0
     leaf_model_name = None
+    backend_need_delete_policy = False
     name = None
     enabled = True
     description = None
@@ -1105,14 +1178,17 @@
     backend_register = "{}"
     backend_need_delete = False
     backend_need_reap = False
-    backend_status = "0 - Provisioning in progress"
+    backend_status = "Provisioning in progress"
+    backend_code = 0
     deleted = False
     write_protect = False
     lazy_blocked = False
     no_sync = False
     no_policy = False
-    policy_status = "0 - Policy in process"
+    policy_status = "Policy in process"
+    policy_code = 0
     leaf_model_name = None
+    backend_need_delete_policy = False
     user = None
     slice = None
     role = None
@@ -1126,14 +1202,17 @@
     backend_register = "{}"
     backend_need_delete = False
     backend_need_reap = False
-    backend_status = "0 - Provisioning in progress"
+    backend_status = "Provisioning in progress"
+    backend_code = 0
     deleted = False
     write_protect = False
     lazy_blocked = False
     no_sync = False
     no_policy = False
-    policy_status = "0 - Policy in process"
+    policy_status = "Policy in process"
+    policy_code = 0
     leaf_model_name = None
+    backend_need_delete_policy = False
     role = None
     
     leaf_model_name = "SliceRole"
@@ -1145,14 +1224,17 @@
     backend_register = "{}"
     backend_need_delete = False
     backend_need_reap = False
-    backend_status = "0 - Provisioning in progress"
+    backend_status = "Provisioning in progress"
+    backend_code = 0
     deleted = False
     write_protect = False
     lazy_blocked = False
     no_sync = False
     no_policy = False
-    policy_status = "0 - Policy in process"
+    policy_status = "Policy in process"
+    policy_code = 0
     leaf_model_name = None
+    backend_need_delete_policy = False
     service = None
     name = None
     value = None
@@ -1168,14 +1250,17 @@
     backend_register = "{}"
     backend_need_delete = False
     backend_need_reap = False
-    backend_status = "0 - Provisioning in progress"
+    backend_status = "Provisioning in progress"
+    backend_code = 0
     deleted = False
     write_protect = False
     lazy_blocked = False
     no_sync = False
     no_policy = False
-    policy_status = "0 - Policy in process"
+    policy_status = "Policy in process"
+    policy_code = 0
     leaf_model_name = None
+    backend_need_delete_policy = False
     name = None
     direction = None
     
@@ -1188,14 +1273,17 @@
     backend_register = "{}"
     backend_need_delete = False
     backend_need_reap = False
-    backend_status = "0 - Provisioning in progress"
+    backend_status = "Provisioning in progress"
+    backend_code = 0
     deleted = False
     write_protect = False
     lazy_blocked = False
     no_sync = False
     no_policy = False
-    policy_status = "0 - Policy in process"
+    policy_status = "Policy in process"
+    policy_code = 0
     leaf_model_name = None
+    backend_need_delete_policy = False
     service = None
     interface_type = None
     
@@ -1208,18 +1296,22 @@
     backend_register = "{}"
     backend_need_delete = False
     backend_need_reap = False
-    backend_status = "0 - Provisioning in progress"
+    backend_status = "Provisioning in progress"
+    backend_code = 0
     deleted = False
     write_protect = False
     lazy_blocked = False
     no_sync = False
     no_policy = False
-    policy_status = "0 - Policy in process"
+    policy_status = "Policy in process"
+    policy_code = 0
     leaf_model_name = None
+    backend_need_delete_policy = False
     name = None
     owner = None
     service_specific_id = None
     service_specific_attribute = None
+    link_deleted_count = 0
     
     leaf_model_name = "ServiceInstance"
 class ServiceInstanceLink(Object):
@@ -1230,14 +1322,17 @@
     backend_register = "{}"
     backend_need_delete = False
     backend_need_reap = False
-    backend_status = "0 - Provisioning in progress"
+    backend_status = "Provisioning in progress"
+    backend_code = 0
     deleted = False
     write_protect = False
     lazy_blocked = False
     no_sync = False
     no_policy = False
-    policy_status = "0 - Policy in process"
+    policy_status = "Policy in process"
+    policy_code = 0
     leaf_model_name = None
+    backend_need_delete_policy = False
     provider_service_instance = None
     provider_service_interface = None
     subscriber_service_instance = None
@@ -1253,14 +1348,17 @@
     backend_register = "{}"
     backend_need_delete = False
     backend_need_reap = False
-    backend_status = "0 - Provisioning in progress"
+    backend_status = "Provisioning in progress"
+    backend_code = 0
     deleted = False
     write_protect = False
     lazy_blocked = False
     no_sync = False
     no_policy = False
-    policy_status = "0 - Policy in process"
+    policy_status = "Policy in process"
+    policy_code = 0
     leaf_model_name = None
+    backend_need_delete_policy = False
     name = None
     value = None
     service_instance = None
@@ -1274,18 +1372,22 @@
     backend_register = "{}"
     backend_need_delete = False
     backend_need_reap = False
-    backend_status = "0 - Provisioning in progress"
+    backend_status = "Provisioning in progress"
+    backend_code = 0
     deleted = False
     write_protect = False
     lazy_blocked = False
     no_sync = False
     no_policy = False
-    policy_status = "0 - Policy in process"
+    policy_status = "Policy in process"
+    policy_code = 0
     leaf_model_name = None
+    backend_need_delete_policy = False
     name = None
     owner = None
     service_specific_id = None
     service_specific_attribute = None
+    link_deleted_count = 0
     instance = None
     creator = None
     external_hostname = None
@@ -1300,14 +1402,17 @@
     backend_register = "{}"
     backend_need_delete = False
     backend_need_reap = False
-    backend_status = "0 - Provisioning in progress"
+    backend_status = "Provisioning in progress"
+    backend_code = 0
     deleted = False
     write_protect = False
     lazy_blocked = False
     no_sync = False
     no_policy = False
-    policy_status = "0 - Policy in process"
+    policy_status = "Policy in process"
+    policy_code = 0
     leaf_model_name = None
+    backend_need_delete_policy = False
     name = "XOS"
     
     leaf_model_name = "XOS"
@@ -1319,17 +1424,18 @@
     backend_register = "{}"
     backend_need_delete = False
     backend_need_reap = False
-    backend_status = "0 - Provisioning in progress"
+    backend_status = "Provisioning in progress"
+    backend_code = 0
     deleted = False
     write_protect = False
     lazy_blocked = False
     no_sync = False
     no_policy = False
-    policy_status = "0 - Policy in process"
+    policy_status = "Policy in process"
+    policy_code = 0
     leaf_model_name = None
+    backend_need_delete_policy = False
     name = None
     files = None
     
     leaf_model_name = "XOSGuiExtension"
-
-
diff --git a/xos/synchronizers/new_base/model_policies/test_model_policy_tenantwithcontainer.py b/xos/synchronizers/new_base/model_policies/test_model_policy_tenantwithcontainer.py
index 5ea9d77..f6ba6a2 100644
--- a/xos/synchronizers/new_base/model_policies/test_model_policy_tenantwithcontainer.py
+++ b/xos/synchronizers/new_base/model_policies/test_model_policy_tenantwithcontainer.py
@@ -22,95 +22,64 @@
 import os, sys
 from xosconfig import Config
 
-TEST_PATH=os.path.abspath(os.path.dirname(os.path.realpath(__file__)))
-sys.path.append(os.path.join(TEST_PATH, "../../.."))
-sys.path.append(os.path.join(TEST_PATH, "../../new_base/model_policies"))
-
-class MockObject:
-    objects = None
-    def __init__(self, **kwargs):
-        for (k,v) in kwargs.items():
-            setattr(self,k,v)
-    def save(self):
-        pass
-    def delete(self):
-        pass
-
-class MockFlavor(MockObject):
-    name = None
-
-class MockInstance(MockObject):
-    name = None
-
-class MockDeployment(MockObject):
-    name = None
-
-class MockUser(MockObject):
-    email = None
-
-class MockSlice(MockObject):
-    name = None
-
-class MockNode(MockObject):
-    hostname = None
-    site_deployment = None
-
-class MockImage(MockObject):
-    name = None
-
-class MockTenant(MockObject):
-    owner = None
-    deleted = False
-    instance = None
-    creator = None
-    service_specific_attribute = {}
-
-    def get_image(self):
-        return None
+test_path = os.path.abspath(os.path.dirname(os.path.realpath(__file__)))
+xos_dir = os.path.join(test_path, '..', '..', '..')
 
 class TestModelPolicyTenantWithContainer(unittest.TestCase):
     def setUp(self):
         global TenantWithContainerPolicy, LeastLoadedNodeScheduler
 
+        self.sys_path_save = sys.path
+        self.cwd_save = os.getcwd()
+        sys.path.append(xos_dir)
+        #sys.path.append(os.path.join(xos_dir, 'synchronizers', 'new_base'))
+        sys.path.append(os.path.join(xos_dir, 'synchronizers', 'new_base', 'model_policies'))
+
         config = basic_conf = os.path.abspath(os.path.dirname(os.path.realpath(__file__)) + "/test_config.yaml")
         Config.clear() # in case left unclean by a previous test case
         Config.init(config, 'synchronizer-config-schema.yaml')
-        import synchronizers.new_base.modelaccessor
         import model_policy_tenantwithcontainer
         from model_policy_tenantwithcontainer import TenantWithContainerPolicy, LeastLoadedNodeScheduler
 
+        # import all class names to globals
+        for (k, v) in model_policy_tenantwithcontainer.model_accessor.all_model_classes.items():
+            globals()[k] = v
+
+        # TODO: Mock_model_accessor lacks save or delete methods
+        #Instance.save = mock.Mock
+        #Instance.delete = mock.Mock
+        #TenantWithContainer.save = mock.Mock
+
         self.policy = TenantWithContainerPolicy()
-        self.user = MockUser(email="testadmin@test.org")
-        self.tenant = MockTenant(creator=self.user)
-        self.flavor = MockFlavor(name="m1.small")
-        model_policy_tenantwithcontainer.Instance = MockInstance
-        model_policy_tenantwithcontainer.Flavor = MockFlavor
+        self.user = User(email="testadmin@test.org")
+        self.tenant = TenantWithContainer(creator=self.user)
+        self.flavor = Flavor(name="m1.small")
 
     def tearDown(self):
         Config.clear()
+        sys.path = self.sys_path_save
+        os.chdir(self.cwd_save)
 
-    @patch.object(MockTenant, "owner")
-    def test_manage_container_no_slices(self, owner):
-        owner.slices.count.return_value = 0
-        with self.assertRaises(Exception) as e:
-            self.policy.manage_container(self.tenant)
-        self.assertEqual(e.exception.message, "The service has no slices")
+    def test_manage_container_no_slices(self):
+        with patch.object(TenantWithContainer, "owner") as owner:
+            owner.slices.count.return_value = 0
+            with self.assertRaises(Exception) as e:
+                self.policy.manage_container(self.tenant)
+            self.assertEqual(e.exception.message, "The service has no slices")
 
-    @patch.object(MockTenant, "owner")
-    @patch.object(MockTenant, "save")
-    #@patch.object(TenantWithContainerPolicy, "get_image")
-    #@patch.object(LeastLoadedNodeScheduler, "pick")
-    @patch.object(MockNode, "site_deployment")
-    @patch.object(MockInstance, "save")
-    @patch.object(MockInstance, "delete")
-    def test_manage_container(self, instance_delete, instance_save, site_deployment, tenant_save, owner):
-      with patch.object(TenantWithContainerPolicy, "get_image") as get_image, \
+    def test_manage_container(self):
+      with patch.object(TenantWithContainer, "owner") as owner, \
+           patch.object(TenantWithContainer, "save") as tenant_save, \
+           patch.object(Node, "site_deployment") as site_deployment, \
+           patch.object(Instance, "save") as instance_save, \
+           patch.object(Instance, "delete") as instance_delete, \
+           patch.object(TenantWithContainerPolicy, "get_image") as get_image, \
            patch.object(LeastLoadedNodeScheduler, "pick") as pick:
         # setup mocks
-        node = MockNode(hostname="my.node.com")
-        slice = MockSlice(name="mysite_test1", default_flavor=self.flavor, default_isolation="vm")
-        image = MockImage(name="trusty-server-multi-nic")
-        deployment = MockDeployment(name="testdeployment")
+        node = Node(hostname="my.node.com")
+        slice = Slice(name="mysite_test1", default_flavor=self.flavor, default_isolation="vm")
+        image = Image(name="trusty-server-multi-nic")
+        deployment = Deployment(name="testdeployment")
         owner.slices.count.return_value = 1
         owner.slices.all.return_value = [slice]
         owner.slices.first.return_value = slice
@@ -144,22 +113,17 @@
         # make sure manage_container did what it is supposed to do
         self.assertEqual(self.tenant.instance, None)
 
-    @patch.object(MockTenant, "owner")
-    @patch.object(MockTenant, "save")
-    #@patch.object(TenantWithContainerPolicy, "get_image")
-    #@patch.object(LeastLoadedNodeScheduler, "pick")
-    @patch.object(MockNode, "site_deployment")
-    @patch.object(MockInstance, "save")
-    @patch.object(MockInstance, "delete")
-    @patch.object(MockFlavor, "objects")
-    def test_manage_container_no_m1_small(self, flavor_objects, instance_delete, instance_save, site_deployment, tenant_save, owner):
-      with patch.object(TenantWithContainerPolicy, "get_image") as get_image, \
+    def test_manage_container_no_m1_small(self):
+      with patch.object(TenantWithContainer, "owner") as owner, \
+           patch.object(Node, "site_deployment") as site_deployment, \
+           patch.object(Flavor, "objects") as flavor_objects, \
+           patch.object(TenantWithContainerPolicy, "get_image") as get_image, \
                 patch.object(LeastLoadedNodeScheduler, "pick") as pick:
         # setup mocks
-        node = MockNode(hostname="my.node.com")
-        slice = MockSlice(name="mysite_test1", default_flavor=None, default_isolation="vm")
-        image = MockImage(name="trusty-server-multi-nic")
-        deployment = MockDeployment(name="testdeployment")
+        node = Node(hostname="my.node.com")
+        slice = Slice(name="mysite_test1", default_flavor=None, default_isolation="vm")
+        image = Image(name="trusty-server-multi-nic")
+        deployment = Deployment(name="testdeployment")
         owner.slices.count.return_value = 1
         owner.slices.all.return_value = [slice]
         owner.slices.first.return_value = slice