diff --git a/VERSION b/VERSION
index f092941..a880003 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-3.2.8
+3.2.9-dev
diff --git a/lib/xos-api/tests/test_config.yaml b/lib/xos-api/tests/test_config.yaml
index ae389f4..b13128e 100644
--- a/lib/xos-api/tests/test_config.yaml
+++ b/lib/xos-api/tests/test_config.yaml
@@ -20,6 +20,7 @@
   handlers:
     console:
       class: logging.StreamHandler
+      level: WARNING
   loggers:
     'multistructlog':
       handlers:
diff --git a/lib/xos-api/tests/test_orm.py b/lib/xos-api/tests/test_orm.py
index 86be969..6a59713 100644
--- a/lib/xos-api/tests/test_orm.py
+++ b/lib/xos-api/tests/test_orm.py
@@ -22,10 +22,10 @@
 
 try:  # python 3
     from io import StringIO
-    from unittest.mock import patch
+    from unittest.mock import patch, MagicMock
 except ImportError:  # python 2
     from StringIO import StringIO
-    from mock import patch
+    from mock import patch, MagicMock
 
 
 # by default, use fake stub rather than real core
@@ -34,7 +34,7 @@
 PARENT_DIR = os.path.join(os.path.dirname(__file__), "..")
 
 
-class TestORM(unittest.TestCase):
+class ORMTestBaseClass(unittest.TestCase):
     def setUp(self):
         from xosconfig import Config
 
@@ -51,6 +51,8 @@
         self.ORMQuerySet = ORMQuerySet
         self.ORMLocalObjectManager = ORMLocalObjectManager
 
+        self.orm = self.make_coreapi()
+
     def tearDown(self):
         if USE_FAKE_STUB:
             sys.path.remove(PARENT_DIR)
@@ -74,576 +76,22 @@
         else:
             return xos_grpc_client.coreapi
 
-    def test_repr_name(self):
-        orm = self.make_coreapi()
-        s = orm.Slice(name="foo")
-        self.assertNotEqual(s, None)
-        self.assertEqual(repr(s), "<Slice: foo>")
 
-    def test_str_name(self):
-        orm = self.make_coreapi()
-        s = orm.Slice(name="foo")
-        self.assertNotEqual(s, None)
-        self.assertEqual(str(s), "foo")
+class TestORMWrapper(ORMTestBaseClass):
+    """ Tests for the ORMWrapper class """
 
-    def test_dumpstr_name(self):
-        orm = self.make_coreapi()
-        s = orm.Slice(name="foo")
-        self.assertNotEqual(s, None)
-        self.assertEqual(s.dumpstr(), 'name: "foo"\n')
-
-    def test_repr_noname(self):
-        orm = self.make_coreapi()
-        s = orm.Slice()
-        self.assertNotEqual(s, None)
-        self.assertEqual(repr(s), "<Slice: id-0>")
-
-    def test_str_noname(self):
-        orm = self.make_coreapi()
-        s = orm.Slice()
-        self.assertNotEqual(s, None)
-        self.assertEqual(str(s), "Slice-0")
-
-    def test_dumpstr_noname(self):
-        orm = self.make_coreapi()
-        s = orm.Slice()
-        self.assertNotEqual(s, None)
-        self.assertEqual(s.dumpstr(), "")
-
-    def test_dump(self):
-        """ dump() is like dumpstr() but prints to stdout. Mock stdout by using a stringIO. """
-
-        orm = self.make_coreapi()
-        s = orm.Slice(name="foo")
-        self.assertNotEqual(s, None)
-        with patch("sys.stdout", new_callable=StringIO) as mock_stdout:
-            s.dump()
-            self.assertEqual(mock_stdout.getvalue(), 'name: "foo"\n\n')
-
-    def test_create(self):
-        orm = self.make_coreapi()
-        site = orm.Site(name="mysite")
-        site.save()
-        self.assertTrue(site.id > 0)
-
-    def test_get(self):
-        orm = self.make_coreapi()
-        site = orm.Site(name="mysite")
-        site.save()
-        self.assertTrue(site.id > 0)
-        got_site = orm.Site.objects.get(id=site.id)
-        self.assertNotEqual(got_site, None)
-        self.assertEqual(got_site.id, site.id)
-
-    def test_invalidate_cache(self):
-        orm = self.make_coreapi()
-        testModel = orm.TestModel()
-
-        # populate the caches with some placeholders we can test for
-        testModel.cache = {"a": 1}
-        testModel.reverse_cache = {"b": 2}
-
-        testModel.invalidate_cache()
-
-        self.assertEqual(testModel.cache, {})
-        self.assertEqual(testModel.reverse_cache, {})
-
-    def test_save_new(self):
-        orm = self.make_coreapi()
-        site = orm.Site(name="mysite")
-        site.save()
-        self.assertTrue(site.id > 0)
-
-    def test_save_existing(self):
-        orm = self.make_coreapi()
-        orig_len_sites = len(orm.Site.objects.all())
-        site = orm.Site(name="mysite")
-        site.save()
-        self.assertTrue(site.id > 0)
-
-        # there should be one new site
-        self.assertEqual(len(orm.Site.objects.all()), orig_len_sites + 1)
-
-        # retrieve the site, and update it
-        created_site_id = site.id
-        site = orm.Site.objects.get(id=created_site_id)
-        site.name = "mysitetwo"
-        site.save()
-
-        # the site_id should not have changed
-        self.assertEqual(site.id, created_site_id)
-
-        # there should still be only one new site
-        self.assertEqual(len(orm.Site.objects.all()), orig_len_sites + 1)
-
-        # the name should have changed
-        self.assertEqual(orm.Site.objects.get(id=created_site_id).name, "mysitetwo")
-
-    def test_delete(self):
-        orm = self.make_coreapi()
-        orig_len_sites = len(orm.Site.objects.all())
-        site = orm.Site(name="mysite")
-        site.save()
-        self.assertTrue(site.id > 0)
-        site.delete()
-        sites = orm.Site.objects.all()
-        self.assertEqual(len(sites), orig_len_sites)
-
-    def test_objects_all(self):
-        orm = self.make_coreapi()
-        orig_len_sites = len(orm.Site.objects.all())
-        site = orm.Site(name="mysite")
-        site.save()
-        sites = orm.Site.objects.all()
-        self.assertEqual(len(sites), orig_len_sites + 1)
-
-    def test_objects_first(self):
-        orm = self.make_coreapi()
-        site = orm.Site(name="mysite")
-        site.save()
-        site = orm.Site.objects.first()
-        self.assertNotEqual(site, None)
-
-    def test_content_type_map(self):
-        orm = self.make_coreapi()
-        self.assertTrue("Slice" in orm.content_type_map.values())
-        self.assertTrue("Site" in orm.content_type_map.values())
-        self.assertTrue("Tag" in orm.content_type_map.values())
-
-    def test_foreign_key_get(self):
-        orm = self.make_coreapi()
-        site = orm.Site(name="mysite")
-        site.save()
-        self.assertTrue(site.id > 0)
-        user = orm.User(
-            email="fake_"
-            + "".join(
-                random.choice(string.ascii_uppercase + string.digits) for _ in range(10)
-            ),
-            site_id=site.id,
-        )
-        user.save()
-        self.assertTrue(user.id > 0)
-        slice = orm.Slice(name="mysite_foo", site_id=site.id, creator_id=user.id)
-        slice.save()
-        self.assertTrue(slice.id > 0)
-        self.assertNotEqual(slice.site, None)
-        self.assertEqual(slice.site.id, site.id)
-
-    def test_foreign_key_set_with_invalidate(self):
-        orm = self.make_coreapi()
-        site = orm.Site(name="mysite")
-        site.save()
-        self.assertTrue(site.id > 0)
-        user = orm.User(
-            email="fake_"
-            + "".join(
-                random.choice(string.ascii_uppercase + string.digits) for _ in range(10)
-            ),
-            site_id=site.id,
-        )
-        user.save()
-        self.assertTrue(user.id > 0)
-        slice = orm.Slice(name="mysite_foo", site=site, creator_id=user.id)
-        slice.save()
-        slice.invalidate_cache()
-        self.assertTrue(slice.id > 0)
-        self.assertNotEqual(slice.site, None)
-        self.assertEqual(slice.site.id, site.id)
-        if not USE_FAKE_STUB:
-            self.assertTrue(slice.id in slice.site.slices_ids)
-
-    def test_foreign_key_set_without_invalidate(self):
-        orm = self.make_coreapi()
-        site = orm.Site(name="mysite")
-        site.save()
-        self.assertTrue(site.id > 0)
-        user = orm.User(
-            email="fake_"
-            + "".join(
-                random.choice(string.ascii_uppercase + string.digits) for _ in range(10)
-            ),
-            site_id=site.id,
-        )
-        user.save()
-        self.assertTrue(user.id > 0)
-        slice = orm.Slice(name="mysite_foo", site=site, creator_id=user.id)
-        slice.save()
-        self.assertTrue(slice.id > 0)
-        self.assertNotEqual(slice.site, None)
-        self.assertEqual(slice.site.id, site.id)
-        if not USE_FAKE_STUB:
-            self.assertTrue(slice.id in slice.site.slices_ids)
-            ids_from_models = [x.id for x in slice.site.slices.all()]
-            self.assertTrue(slice.id in ids_from_models)
-
-    def test_foreign_key_reset(self):
-        orm = self.make_coreapi()
-        site = orm.Site(name="mysite")
-        site.save()
-        self.assertTrue(site.id > 0)
-        user = orm.User(
-            email="fake_"
-            + "".join(
-                random.choice(string.ascii_uppercase + string.digits) for _ in range(10)
-            ),
-            site_id=site.id,
-        )
-        user.save()
-        self.assertTrue(user.id > 0)
-        slice = orm.Slice(name="mysite_foo", site=site, creator_id=user.id)
-        slice.save()
-        self.assertTrue(slice.id > 0)
-        self.assertNotEqual(slice.site, None)
-        self.assertEqual(slice.site.id, site.id)
-        if not USE_FAKE_STUB:
-            self.assertTrue(slice.id in site.slices_ids)
-            self.assertTrue(slice.id in slice.site.slices_ids)
-
-        site2 = orm.Site(name="mysite2")
-        site2.save()
-        slice.name = "mysite2_foo"
-        slice.site = site2
-        slice.save()
-        self.assertNotEqual(slice.site, None)
-        self.assertEqual(slice.site.id, site2.id)
-        if not USE_FAKE_STUB:
-            self.assertTrue(slice.id not in site.slices_ids)
-            self.assertTrue(slice.id in site2.slices_ids)
-            self.assertTrue(slice.id in slice.site.slices_ids)
-            ids_from_models1 = [x.id for x in site.slices.all()]
-            self.assertTrue(slice.id not in ids_from_models1)
-            ids_from_models2 = [x.id for x in site2.slices.all()]
-            self.assertTrue(slice.id in ids_from_models2)
-
-    def test_foreign_key_back_and_forth_even(self):
-        orm = self.make_coreapi()
-        site = orm.Site(name="mysite")
-        site.save()
-        self.assertTrue(site.id > 0)
-        user = orm.User(
-            email="fake_"
-            + "".join(
-                random.choice(string.ascii_uppercase + string.digits) for _ in range(10)
-            ),
-            site_id=site.id,
-        )
-        user.save()
-        self.assertTrue(user.id > 0)
-        slice = orm.Slice(name="mysite_foo", site=site, creator_id=user.id)
-        slice.save()
-        self.assertTrue(slice.id > 0)
-        self.assertNotEqual(slice.site, None)
-        self.assertEqual(slice.site.id, site.id)
-        if not USE_FAKE_STUB:
-            self.assertTrue(slice.id in site.slices_ids)
-            self.assertTrue(slice.id in slice.site.slices_ids)
-
-        site2 = orm.Site(name="mysite2")
-        site2.save()
-        slice.name = "mysite2_foo"
-        slice.site = site2
-        slice.site = site
-        slice.site = site2
-        slice.site = site
-        slice.save()
-        self.assertNotEqual(slice.site, None)
-        self.assertEqual(slice.site.id, site.id)
-        if not USE_FAKE_STUB:
-            self.assertTrue(slice.id not in site2.slices_ids)
-            self.assertTrue(slice.id in site.slices_ids)
-            self.assertTrue(slice.id in slice.site.slices_ids)
-
-    def test_foreign_key_back_and_forth_odd(self):
-        orm = self.make_coreapi()
-        site = orm.Site(name="mysite")
-        site.save()
-        self.assertTrue(site.id > 0)
-        user = orm.User(
-            email="fake_"
-            + "".join(
-                random.choice(string.ascii_uppercase + string.digits) for _ in range(10)
-            ),
-            site_id=site.id,
-        )
-        user.save()
-        self.assertTrue(user.id > 0)
-        slice = orm.Slice(name="mysite_foo", site=site, creator_id=user.id)
-        slice.save()
-        self.assertTrue(slice.id > 0)
-        self.assertNotEqual(slice.site, None)
-        self.assertEqual(slice.site.id, site.id)
-        if not USE_FAKE_STUB:
-            self.assertTrue(slice.id in site.slices_ids)
-            self.assertTrue(slice.id in slice.site.slices_ids)
-
-        site2 = orm.Site(name="mysite2")
-        site2.save()
-        slice.name = "mysite2_foo"
-        slice.site = site2
-        slice.site = site
-        slice.site = site2
-        slice.site = site
-        slice.site = site2
-        slice.save()
-        self.assertNotEqual(slice.site, None)
-        self.assertEqual(slice.site.id, site2.id)
-        if not USE_FAKE_STUB:
-            self.assertTrue(slice.id not in site.slices_ids)
-            self.assertTrue(slice.id in site2.slices_ids)
-            self.assertTrue(slice.id in slice.site.slices_ids)
-
-    def test_foreign_key_create_null(self):
-        orm = self.make_coreapi()
-        site = orm.Site(name="mysite")
-        site.save()
-        self.assertTrue(site.id > 0)
-        user = orm.User(
-            email="fake_"
-            + "".join(
-                random.choice(string.ascii_uppercase + string.digits) for _ in range(10)
-            ),
-            site_id=site.id,
-        )
-        user.save()
-        self.assertTrue(user.id > 0)
-        slice = orm.Slice(
-            name="mysite_foo", site=site, service=None, creator_id=user.id
-        )
-        slice.save()
-        slice.invalidate_cache()
-        self.assertTrue(slice.id > 0)
-        self.assertEqual(slice.service, None)
-
-    def test_foreign_key_set_null(self):
-        orm = self.make_coreapi()
-        site = orm.Site(name="mysite")
-        site.save()
-        self.assertTrue(site.id > 0)
-        user = orm.User(
-            email="fake_"
-            + "".join(
-                random.choice(string.ascii_uppercase + string.digits) for _ in range(10)
-            ),
-            site_id=site.id,
-        )
-        user.save()
-        self.assertTrue(user.id > 0)
-        service = orm.Service(name="myservice")
-        service.save()
-        self.assertTrue(service.id > 0)
-        # start out slice.service is non-None
-        slice = orm.Slice(
-            name="mysite_foo", site=site, service=service, creator_id=user.id
-        )
-        slice.save()
-        slice.invalidate_cache()
-        self.assertTrue(slice.id > 0)
-        self.assertNotEqual(slice.service, None)
-        self.assertEqual(slice.service.id, service.id)
-        # now set it to None
-        slice.service = None
-        slice.save()
-        slice.invalidate_cache()
-        self.assertEqual(slice.service, None)
-
-    def test_generic_foreign_key_get(self):
-        orm = self.make_coreapi()
-        service = orm.Service(name="myservice")
-        service.save()
-        site = orm.Site(name="mysite")
-        site.save()
-        self.assertTrue(site.id > 0)
-        tag = orm.Tag(
-            service=service,
-            name="mytag",
-            value="somevalue",
-            content_type=site.self_content_type_id,
-            object_id=site.id,
-        )
-        tag.save()
-        self.assertTrue(tag.id > 0)
-        self.assertNotEqual(tag.content_object, None)
-        self.assertEqual(tag.content_object.id, site.id)
-
-    def test_generic_foreign_key_get_decl(self):
-        orm = self.make_coreapi()
-        service = orm.Service(name="myservice")
-        service.save()
-        site = orm.Site(name="mysite")
-        site.save()
-        self.assertTrue(site.id > 0)
-        tag = orm.Tag(
-            service=service,
-            name="mytag",
-            value="somevalue",
-            content_type=site.self_content_type_id + "_decl",
-            object_id=site.id,
-        )
-        tag.save()
-        self.assertTrue(tag.id > 0)
-        self.assertNotEqual(tag.content_object, None)
-        self.assertEqual(tag.content_object.id, site.id)
-
-    def test_generic_foreign_key_get_bad_contenttype(self):
-        orm = self.make_coreapi()
-        service = orm.Service(name="myservice")
-        service.save()
-        site = orm.Site(name="mysite")
-        site.save()
-        self.assertTrue(site.id > 0)
-        tag = orm.Tag(
-            service=service,
-            name="mytag",
-            value="somevalue",
-            content_type="does_not_exist",
-            object_id=site.id,
-        )
-        tag.save()
-        self.assertTrue(tag.id > 0)
-        with self.assertRaises(Exception) as e:
-
-            self.assertEqual(
-                str(e.exception),
-                "Content_type does_not_exist not found in self.content_type_map",
-            )
-
-    def test_generic_foreign_key_get_bad_id(self):
-        orm = self.make_coreapi()
-        service = orm.Service(name="myservice")
-        service.save()
-        site = orm.Site(name="mysite")
-        site.save()
-        self.assertTrue(site.id > 0)
-        tag = orm.Tag(
-            service=service,
-            name="mytag",
-            value="somevalue",
-            content_type=site.self_content_type_id,
-            object_id=4567,
-        )
-        tag.save()
-        self.assertTrue(tag.id > 0)
-        with self.assertRaises(Exception) as e:
-            self.assertEqual(
-                str(e.exception), "Object 4567 of model Site was not found"
-            )
-
-    def test_generic_foreign_key_set(self):
-        orm = self.make_coreapi()
-        service = orm.Service(name="myservice")
-        service.save()
-        site = orm.Site(name="mysite")
-        site.save()
-        self.assertTrue(site.id > 0)
-        tag = orm.Tag(service=service, name="mytag", value="somevalue")
-        tag.content_object = site
-        tag.invalidate_cache()
-        self.assertEqual(tag.content_type, site.self_content_type_id)
-        self.assertEqual(tag.object_id, site.id)
-        tag.save()
-        self.assertTrue(tag.id > 0)
-        self.assertNotEqual(tag.content_object, None)
-        self.assertEqual(tag.content_object.id, site.id)
-
-    def test_leaf_model_trivial(self):
-        orm = self.make_coreapi()
-        service = orm.Service(name="myservice")
-        service.save()
-        self.assertEqual(service.leaf_model_name, "Service")
-
-    def test_leaf_model_descendant(self):
-        orm = self.make_coreapi()
-        onos_service = orm.ONOSService(name="myservice")
-        onos_service.save()
-        self.assertEqual(onos_service.model_name, "ONOSService")
-        self.assertEqual(onos_service.leaf_model_name, "ONOSService")
-
-        service = orm.Service.objects.get(id=onos_service.id)
-        self.assertEqual(service.id, onos_service.id)
-        self.assertEqual(service.model_name, "Service")
-        self.assertEqual(service.leaf_model_name, "ONOSService")
-
-        onos_service_cast = service.leaf_model
-        self.assertEqual(onos_service_cast.model_name, "ONOSService")
-        self.assertEqual(onos_service_cast.leaf_model_name, "ONOSService")
-        self.assertEqual(onos_service_cast.id, onos_service.id)
-
-    def test_field_null(self):
-        """ In a saved object, if a nullable field is left set to None, make sure the ORM returns None """
-
-        orm = self.make_coreapi()
-        tm = orm.TestModel()
-        tm.save()
-
-        tm = orm.TestModel.objects.all()[0]
-        self.assertFalse(tm._wrapped_class.HasField("intfield"))
-        self.assertEqual(tm.intfield, None)
-
-    def test_field_null_new(self):
-        """ For models that haven't been saved yet, reading the field should return the gRPC default """
-
-        orm = self.make_coreapi()
-        tm = orm.TestModel()
-
-        self.assertEqual(tm.intfield, 0)
-
-    def test_field_non_null(self):
-        """ In a saved object, if a nullable field is set to a value, then make sure the ORM returns the value """
-
-        orm = self.make_coreapi()
-        tm = orm.TestModel(intfield=3)
-        tm.save()
-
-        tm = orm.TestModel.objects.all()[0]
-        self.assertEqual(tm.intfield, 3)
-
-    def test_field_set_null(self):
-        """ Setting a field to None is not allowed """
-
-        orm = self.make_coreapi()
-        tm = orm.TestModel()
-        with self.assertRaises(Exception) as e:
-            tm.intfile = None
-        self.assertEqual(
-            str(e.exception),
-            "Setting a non-foreignkey field to None is not supported",
-        )
-
-    def test_query_iexact(self):
-        orm = self.make_coreapi()
-        with patch.object(orm.grpc_stub, "FilterTestModel", autospec=True) as filter:
-            orm.TestModel.objects.filter(name__iexact="foo")
-            self.assertEqual(filter.call_count, 1)
-            q = filter.call_args[0][0]
-
-            self.assertEqual(q.kind, q.DEFAULT)
-            self.assertEqual(len(q.elements), 1)
-            self.assertEqual(q.elements[0].operator, q.elements[0].IEXACT)
-            self.assertEqual(q.elements[0].sValue, "foo")
-
-    def test_query_equal(self):
-        orm = self.make_coreapi()
-        with patch.object(orm.grpc_stub, "FilterTestModel", autospec=True) as filter:
-            orm.TestModel.objects.filter(name="foo")
-            self.assertEqual(filter.call_count, 1)
-            q = filter.call_args[0][0]
-
-            self.assertEqual(q.kind, q.DEFAULT)
-            self.assertEqual(len(q.elements), 1)
-            self.assertEqual(q.elements[0].operator, q.elements[0].EQUAL)
-            self.assertEqual(q.elements[0].sValue, "foo")
+    def test_ORMWrapper_fields_differ(self):
+        testModel = self.orm.TestModel(intfield=7, stringfield="foo")
+        self.assertTrue(testModel.fields_differ("a", "b"))
+        self.assertFalse(testModel.fields_differ("a", "a"))
 
     def test_ORMWrapper_dict(self):
-        orm = self.make_coreapi()
-
-        testModel = orm.TestModel(intfield=7, stringfield="foo")
+        testModel = self.orm.TestModel(intfield=7, stringfield="foo")
 
         self.assertDictEqual(testModel._dict, {"intfield": 7, "stringfield": "foo"})
 
     def test_ORMWrapper_new_diff(self):
-        orm = self.make_coreapi()
-        site = orm.Site(name="mysite")
+        site = self.orm.Site(name="mysite")
 
         self.assertEqual(site.is_new, True)
         self.assertEqual(site._dict, {"name": "mysite"})
@@ -651,6 +99,7 @@
         self.assertEqual(site.changed_fields, ["name"])
         self.assertEqual(site.has_field_changed("name"), False)
         self.assertEqual(site.has_field_changed("login_base"), False)
+        self.assertEqual(site.has_changed, False)
 
         site.login_base = "bar"
 
@@ -660,13 +109,13 @@
         self.assertIn("login_base", site.changed_fields)
         self.assertEqual(site.has_field_changed("name"), False)
         self.assertEqual(site.has_field_changed("login_base"), True)
+        self.assertEqual(site.has_changed, True)
         self.assertEqual(site.get_field_diff("login_base"), (None, "bar"))
 
     def test_ORMWrapper_existing_diff(self):
-        orm = self.make_coreapi()
-        site = orm.Site(name="mysite", login_base="foo")
+        site = self.orm.Site(name="mysite", login_base="foo")
         site.save()
-        site = orm.Site.objects.first()
+        site = self.orm.Site.objects.first()
 
         self.assertEqual(site.is_new, False)
         self.assertEqual(site._dict, {"id": 1, "name": "mysite", "login_base": "foo"})
@@ -674,6 +123,7 @@
         self.assertEqual(site.changed_fields, [])
         self.assertEqual(site.has_field_changed("name"), False)
         self.assertEqual(site.has_field_changed("login_base"), False)
+        self.assertEqual(site.has_changed, False)
 
         site.login_base = "bar"
 
@@ -682,12 +132,12 @@
         self.assertIn("login_base", site.changed_fields)
         self.assertEqual(site.has_field_changed("name"), False)
         self.assertEqual(site.has_field_changed("login_base"), True)
+        self.assertEqual(site.has_changed, True)
 
     def test_ORMWrapper_diff_after_save(self):
-        orm = self.make_coreapi()
-        site = orm.Site(name="mysite", login_base="foo")
+        site = self.orm.Site(name="mysite", login_base="foo")
         site.save()
-        site = orm.Site.objects.first()
+        site = self.orm.Site.objects.first()
 
         self.assertEqual(site.diff, {})
 
@@ -704,9 +154,7 @@
             from the diff set.
         """
 
-        orm = self.make_coreapi()
-
-        testModel = orm.TestModel()
+        testModel = self.orm.TestModel()
         testModel.save()
 
         testModel.intfield = 9
@@ -715,23 +163,14 @@
         testModel.recompute_initial()
         self.assertEqual(testModel.changed_fields, [])
 
-    def test_ORMWrapper_create_attr(self):
-        orm = self.make_coreapi()
-
-        testModel = orm.TestModel()
-        testModel.create_attr("some_new_attribute", "foo")
-        self.assertEqual(testModel.some_new_attribute, "foo")
-
     def test_ORMWrapper_save_changed_fields(self):
-        orm = self.make_coreapi()
-
-        testModel = orm.TestModel(intfield=7, stringfield="foo")
+        testModel = self.orm.TestModel(intfield=7, stringfield="foo")
         testModel.save()
 
         testModel.intfield = 9
 
         with patch.object(
-            orm.grpc_stub, "UpdateTestModel", wraps=orm.grpc_stub.UpdateTestModel
+            self.orm.grpc_stub, "UpdateTestModel", wraps=self.orm.grpc_stub.UpdateTestModel
         ) as update:
             testModel.save_changed_fields()
 
@@ -742,20 +181,21 @@
             ]
             self.assertEqual(update_fields_arg, ["intfield"])
 
+    def test_ORMWrapper_create_attr(self):
+        testModel = self.orm.TestModel()
+        testModel.create_attr("some_new_attribute", "foo")
+        self.assertEqual(testModel.some_new_attribute, "foo")
+
     def test_ORMWrapper_get_generic_foreignkeys(self):
         """ Currently this is a placeholder that returns an empty list """
 
-        orm = self.make_coreapi()
-
-        testModel = orm.TestModel()
+        testModel = self.orm.TestModel()
         self.assertEqual(testModel.get_generic_foreignkeys(), [])
 
     def test_ORMWrapper_gen_fkmap(self):
         """ TestModelTwo includes a foreignkey relation to TestModel, and the fkmap should contain that relation """
 
-        orm = self.make_coreapi()
-
-        testModelTwo = orm.TestModelTwo()
+        testModelTwo = self.orm.TestModelTwo()
 
         self.assertDictEqual(
             testModelTwo.gen_fkmap(),
@@ -774,9 +214,7 @@
             relation.
         """
 
-        orm = self.make_coreapi()
-
-        testModel = orm.TestModel()
+        testModel = self.orm.TestModel()
 
         self.assertDictEqual(
             testModel.gen_reverse_fkmap(),
@@ -794,12 +232,10 @@
             return that model.
         """
 
-        orm = self.make_coreapi()
-
-        testModel = orm.TestModel()
+        testModel = self.orm.TestModel()
         testModel.save()
 
-        testModelTwo = orm.TestModelTwo(testmodel_id=testModel.id)
+        testModelTwo = self.orm.TestModelTwo(testmodel_id=testModel.id)
 
         testModel_resolved = testModelTwo.fk_resolve("testmodel")
         self.assertEqual(testModel_resolved.id, testModel.id)
@@ -812,12 +248,10 @@
             of TestModelTwo objects.
         """
 
-        orm = self.make_coreapi()
-
-        testModel = orm.TestModel()
+        testModel = self.orm.TestModel()
         testModel.save()
 
-        testModelTwo = orm.TestModelTwo(testmodel_id=testModel.id)
+        testModelTwo = self.orm.TestModelTwo(testmodel_id=testModel.id)
         testModelTwo.save()
 
         # fake_stub.py doesn't populate the reverse relations for us, so force what the server would have done...
@@ -834,12 +268,10 @@
     def test_ORMWrapper_fk_set(self):
         """ fk_set will set the testmodel field on TesTModelTwo to point to the TestModel. """
 
-        orm = self.make_coreapi()
-
-        testModel = orm.TestModel()
+        testModel = self.orm.TestModel()
         testModel.save()
 
-        testModelTwo = orm.TestModelTwo()
+        testModelTwo = self.orm.TestModelTwo()
 
         testModelTwo.fk_set("testmodel", testModel)
 
@@ -848,12 +280,10 @@
     def test_ORMWrapper_post_save_fixups_remove(self):
         """ Apply a post_save_fixup that removes a reverse foreign key """
 
-        orm = self.make_coreapi()
-
-        testModel = orm.TestModel()
+        testModel = self.orm.TestModel()
         testModel.save()
 
-        testModelTwo = orm.TestModelTwo(testmodel_id=testModel.id)
+        testModelTwo = self.orm.TestModelTwo(testmodel_id=testModel.id)
 
         # fake_stub.py doesn't populate the reverse relations for us, so force what the server would have done...
         testModel._wrapped_class.testmodeltwos_ids = [testModelTwo.id]
@@ -876,12 +306,10 @@
     def test_ORMWrapper_post_save_fixups_add(self):
         """ Apply a post_save_fixup that adds a reverse foreign key """
 
-        orm = self.make_coreapi()
-
-        testModel = orm.TestModel()
+        testModel = self.orm.TestModel()
         testModel.save()
 
-        testModelTwo = orm.TestModelTwo(testmodel_id=testModel.id)
+        testModelTwo = self.orm.TestModelTwo(testmodel_id=testModel.id)
         testModelTwo.save()
 
         # Make sure the reverse_relation is unpopulated. This should be the case, as fake_stub.py() doesn't populate
@@ -905,61 +333,98 @@
 
     def test_ORMWrapper_tologdict(self):
         """ Tologdict contains the model name and id, used for structured logging """
-        orm = self.make_coreapi()
-
-        testModel = orm.TestModel(intfield=7, stringfile="foo")
+        testModel = self.orm.TestModel(intfield=7, stringfile="foo")
 
         self.assertDictEqual(
             testModel.tologdict(), {"model_name": "TestModel", "pk": 0}
         )
 
+    def test_repr_name(self):
+        s = self.orm.Slice(name="foo")
+        self.assertNotEqual(s, None)
+        self.assertEqual(repr(s), "<Slice: foo>")
+
+    def test_repr_noname(self):
+        s = self.orm.Slice()
+        self.assertNotEqual(s, None)
+        self.assertEqual(repr(s), "<Slice: id-0>")
+
+    def test_str_name(self):
+        s = self.orm.Slice(name="foo")
+        self.assertNotEqual(s, None)
+        self.assertEqual(str(s), "foo")
+
+    def test_str_noname(self):
+        s = self.orm.Slice()
+        self.assertNotEqual(s, None)
+        self.assertEqual(str(s), "Slice-0")
+
+    def test_dumpstr_name(self):
+        s = self.orm.Slice(name="foo")
+        self.assertNotEqual(s, None)
+        self.assertEqual(s.dumpstr(), 'name: "foo"\n')
+
+    def test_dumpstr_noname(self):
+        s = self.orm.Slice()
+        self.assertNotEqual(s, None)
+        self.assertEqual(s.dumpstr(), "")
+
+    def test_dump(self):
+        """ dump() is like dumpstr() but prints to stdout. Mock stdout by using a stringIO. """
+
+        s = self.orm.Slice(name="foo")
+        self.assertNotEqual(s, None)
+        with patch("sys.stdout", new_callable=StringIO) as mock_stdout:
+            s.dump()
+            self.assertEqual(mock_stdout.getvalue(), 'name: "foo"\n\n')
+
+    def test_invalidate_cache(self):
+        testModel = self.orm.TestModel()
+
+        # populate the caches with some placeholders we can test for
+        testModel.cache = {"a": 1}
+        testModel.reverse_cache = {"b": 2}
+
+        testModel.invalidate_cache()
+
+        self.assertEqual(testModel.cache, {})
+        self.assertEqual(testModel.reverse_cache, {})
+
+    def test_leaf_model_trivial(self):
+        service = self.orm.Service(name="myservice")
+        service.save()
+        self.assertEqual(service.leaf_model_name, "Service")
+
+    def test_leaf_model_descendant(self):
+        onos_service = self.orm.ONOSService(name="myservice")
+        onos_service.save()
+        self.assertEqual(onos_service.model_name, "ONOSService")
+        self.assertEqual(onos_service.leaf_model_name, "ONOSService")
+
+        service = self.orm.Service.objects.get(id=onos_service.id)
+        self.assertEqual(service.id, onos_service.id)
+        self.assertEqual(service.model_name, "Service")
+        self.assertEqual(service.leaf_model_name, "ONOSService")
+
+        onos_service_cast = service.leaf_model
+        self.assertEqual(onos_service_cast.model_name, "ONOSService")
+        self.assertEqual(onos_service_cast.leaf_model_name, "ONOSService")
+        self.assertEqual(onos_service_cast.id, onos_service.id)
+
+    def test_ORMWrapper_model_name(self):
+        testModel = self.orm.TestModel()
+        self.assertEqual(testModel.model_name, "TestModel")
+
     def test_ORMWrapper_ansible_tag(self):
         """ Ansible_tag is used by old-style synchronizers. Deprecated. """
 
-        orm = self.make_coreapi()
-
-        testModel = orm.TestModel(id=7)
+        testModel = self.orm.TestModel(id=7)
 
         self.assertEqual(testModel.ansible_tag, "TestModel_7")
 
-    def test_deleted_objects_all(self):
-        orm = self.make_coreapi()
-        orig_len_sites = len(orm.Site.objects.all())
-        orig_len_deleted_sites = len(orm.Site.deleted_objects.all())
-        site = orm.Site(name="mysite")
-        site.save()
-        site.delete()
-        sites = orm.Site.objects.all()
-        self.assertEqual(len(sites), orig_len_sites)
-        deleted_sites = orm.Site.deleted_objects.all()
-        self.assertEqual(len(deleted_sites), orig_len_deleted_sites + 1)
 
-    def test_deleted_objects_filter(self):
-        orm = self.make_coreapi()
-        with patch.object(
-            orm.grpc_stub, "FilterTestModel", wraps=orm.grpc_stub.FilterTestModel
-        ) as filter:
-            foo = orm.TestModel(name="foo")
-            foo.save()
-            foo.delete()
-
-            # There should be no live objects
-            objs = orm.TestModel.objects.filter(name="foo")
-            self.assertEqual(len(objs), 0)
-
-            # There should be one deleted object
-            deleted_objs = orm.TestModel.deleted_objects.filter(name="foo")
-            self.assertEqual(len(deleted_objs), 1)
-
-            # Two calls, one for when we checked live objects, the other for when we checked deleted objects
-            self.assertEqual(filter.call_count, 2)
-            q = filter.call_args[0][0]
-
-            # Now spy on the query that was generated, to make sure it looks like we expect
-            self.assertEqual(q.kind, q.SYNCHRONIZER_DELETED_OBJECTS)
-            self.assertEqual(len(q.elements), 1)
-            self.assertEqual(q.elements[0].operator, q.elements[0].EQUAL)
-            self.assertEqual(q.elements[0].sValue, "foo")
+class TestORMQuerySet(ORMTestBaseClass):
+    """ Tests for high-level ORMQuerySet class """
 
     def test_ORMQuerySet_first_nonempty(self):
         qs = self.ORMQuerySet([1, 2, 3])
@@ -977,13 +442,15 @@
         qs = self.ORMQuerySet()
         self.assertEqual(qs.exists(), False)
 
+
+class TestORMLocalObjectManager(ORMTestBaseClass):
+    """ Tests for high-level ORMLocalObjectManager class """
+
     def test_ORMLocalObjectManager_nonempty(self):
         """ Test all(), first(), exists(), and count() together since they're all closely related. Use a nonempty
             list.
         """
-        orm = self.make_coreapi()
-
-        t = orm.TestModel()
+        t = self.orm.TestModel()
         t.save()
 
         lobjs = self.ORMLocalObjectManager(t.stub, "TestModel", [t.id], False)
@@ -997,9 +464,7 @@
         """ Test all(), first(), exists(), and count() together since they're all closely related. Use an empty
             list.
         """
-        orm = self.make_coreapi()
-
-        t = orm.TestModel()
+        t = self.orm.TestModel()
         t.save()
 
         lobjs = self.ORMLocalObjectManager(t.stub, "TestModel", [], False)
@@ -1010,9 +475,7 @@
 
     def test_ORMLocalObjectManager_not_writeable(self):
         """ An ORMLocalObjectManager that is not writeable should throw exceptions on add() and remove() """
-        orm = self.make_coreapi()
-
-        t = orm.TestModel()
+        t = self.orm.TestModel()
         t.save()
 
         lobjs = self.ORMLocalObjectManager(t.stub, "TestModel", [t.id], False)
@@ -1026,9 +489,7 @@
         self.assertEqual(str(e.exception), "Only ManyToMany lists are writeable")
 
     def test_ORMLocalObjectManager_add(self):
-        orm = self.make_coreapi()
-
-        t = orm.TestModel()
+        t = self.orm.TestModel()
         t.save()
 
         lobjs = self.ORMLocalObjectManager(t.stub, "TestModel", [], True)
@@ -1037,9 +498,7 @@
         self.assertEqual(lobjs.first().id, t.id)
 
     def test_ORMLocalObjectManager_remove(self):
-        orm = self.make_coreapi()
-
-        t = orm.TestModel()
+        t = self.orm.TestModel()
         t.save()
 
         lobjs = self.ORMLocalObjectManager(t.stub, "TestModel", [t.id], True)
@@ -1047,6 +506,558 @@
         self.assertEqual(lobjs.count(), 0)
 
 
+class TestORMObjectManager(ORMTestBaseClass):
+    """ Tests for ORMObjectManager class """
+
+    def test_wrap_single(self):
+        wrapped_obj = self.orm.all_grpc_classes["Site"](name="mysite")
+        orm_obj = self.orm.Site.objects.wrap_single(wrapped_obj)
+        self.assertEqual(orm_obj._wrapped_class, wrapped_obj)
+
+    def test_wrap_list(self):
+        wrapped_obj = self.orm.all_grpc_classes["Site"](name="mysite")
+        wrapped_list = MagicMock(items=[wrapped_obj])
+        orm_objs = self.orm.Site.objects.wrap_list(wrapped_list)
+        self.assertEqual(len(orm_objs), 1)
+        self.assertEqual(orm_objs[0]._wrapped_class, wrapped_obj)
+
+    def test_objects_all(self):
+        orig_len_sites = len(self.orm.Site.objects.all())
+        site = self.orm.Site(name="mysite")
+        site.save()
+        sites = self.orm.Site.objects.all()
+        self.assertEqual(len(sites), orig_len_sites + 1)
+
+    def test_objects_first(self):
+        site = self.orm.Site(name="mysite")
+        site.save()
+        site = self.orm.Site.objects.first()
+        self.assertNotEqual(site, None)
+
+    def test_filter_query_iexact(self):
+        with patch.object(self.orm.grpc_stub, "FilterTestModel", autospec=True) as filter:
+            self.orm.TestModel.objects.filter(name__iexact="foo")
+            self.assertEqual(filter.call_count, 1)
+            q = filter.call_args[0][0]
+
+            self.assertEqual(q.kind, q.DEFAULT)
+            self.assertEqual(len(q.elements), 1)
+            self.assertEqual(q.elements[0].operator, q.elements[0].IEXACT)
+            self.assertEqual(q.elements[0].sValue, "foo")
+
+    def test_filter_query_equal(self):
+        with patch.object(self.orm.grpc_stub, "FilterTestModel", autospec=True) as filter:
+            self.orm.TestModel.objects.filter(name="foo")
+            self.assertEqual(filter.call_count, 1)
+            q = filter.call_args[0][0]
+
+            self.assertEqual(q.kind, q.DEFAULT)
+            self.assertEqual(len(q.elements), 1)
+            self.assertEqual(q.elements[0].operator, q.elements[0].EQUAL)
+            self.assertEqual(q.elements[0].sValue, "foo")
+
+    def test_filter_special(self):
+        with patch.object(self.orm.grpc_stub, "FilterTestModel", autospec=True) as filter:
+            self.orm.TestModel.objects.filter_special(kind=self.orm.TestModel.objects.SYNCHRONIZER_DIRTY_OBJECTS)
+            self.assertEqual(filter.call_count, 1)
+            q = filter.call_args[0][0]
+            self.assertEqual(q.kind, q.SYNCHRONIZER_DIRTY_OBJECTS)
+
+    def test_get(self):
+        site = self.orm.Site(name="mysite")
+        site.save()
+        self.assertTrue(site.id > 0)
+        got_site = self.orm.Site.objects.get(id=site.id)
+        self.assertNotEqual(got_site, None)
+        self.assertEqual(got_site.id, site.id)
+
+    def test_new(self):
+        site = self.orm.Site.objects.new(name="mysite")
+        site.save()
+        self.assertTrue(site.id > 0)
+
+
+class TestORMModelClass(ORMTestBaseClass):
+    """ Tests for ORMModelClass class """
+
+    def test_name(self):
+        self.assertEqual(self.orm.Site.__name__, "Site")
+
+    def test_content_type_id(self):
+        self.assertNotEqual(self.orm.Site.content_type_id, None)
+
+    def test_call(self):
+        new_obj = self.orm.Site(name="mysite")
+        self.assertNotEqual(new_obj, None)
+        self.assertEqual(new_obj.name, "mysite")
+
+
+class TestORM(ORMTestBaseClass):
+    """ Tests for OMRStub and misc high-level ORM operations """
+
+    def test_add_default_metadata(self):
+        md = []
+        self.orm.add_default_metadata(md)
+        self.assertListEqual(md, [('caller_kind', 'grpcapi')])
+
+    def test_make_ID(self):
+        id_proto = self.orm.make_ID(123)
+        self.assertEqual(id_proto.id, 123)
+
+    def test_make_empty(self):
+        empty_proto = self.orm.make_empty()
+        self.assertNotEqual(empty_proto, None)
+
+    def test_make_Query(self):
+        query_proto = self.orm.make_Query()
+        self.assertNotEqual(query_proto, None)
+        self.assertTrue(hasattr(query_proto, "elements"))
+
+    def test_listObjects(self):
+        objs = self.orm.listObjects()
+        self.assertIn("Slice", objs)
+
+    def test_create(self):
+        site = self.orm.Site(name="mysite")
+        site.save()
+        self.assertTrue(site.id > 0)
+
+    def test_save_existing(self):
+        orig_len_sites = len(self.orm.Site.objects.all())
+        site = self.orm.Site(name="mysite")
+        site.save()
+        self.assertTrue(site.id > 0)
+
+        # there should be one new site
+        self.assertEqual(len(self.orm.Site.objects.all()), orig_len_sites + 1)
+
+        # retrieve the site, and update it
+        created_site_id = site.id
+        site = self.orm.Site.objects.get(id=created_site_id)
+        site.name = "mysitetwo"
+        site.save()
+
+        # the site_id should not have changed
+        self.assertEqual(site.id, created_site_id)
+
+        # there should still be only one new site
+        self.assertEqual(len(self.orm.Site.objects.all()), orig_len_sites + 1)
+
+        # the name should have changed
+        self.assertEqual(self.orm.Site.objects.get(id=created_site_id).name, "mysitetwo")
+
+    def test_delete(self):
+        orig_len_sites = len(self.orm.Site.objects.all())
+        site = self.orm.Site(name="mysite")
+        site.save()
+        self.assertTrue(site.id > 0)
+        site.delete()
+        sites = self.orm.Site.objects.all()
+        self.assertEqual(len(sites), orig_len_sites)
+
+    def test_content_type_map(self):
+        self.assertTrue("Slice" in self.orm.content_type_map.values())
+        self.assertTrue("Site" in self.orm.content_type_map.values())
+        self.assertTrue("Tag" in self.orm.content_type_map.values())
+
+    def test_foreign_key_get(self):
+        site = self.orm.Site(name="mysite")
+        site.save()
+        self.assertTrue(site.id > 0)
+        user = self.orm.User(
+            email="fake_"
+            + "".join(
+                random.choice(string.ascii_uppercase + string.digits) for _ in range(10)
+            ),
+            site_id=site.id,
+        )
+        user.save()
+        self.assertTrue(user.id > 0)
+        slice = self.orm.Slice(name="mysite_foo", site_id=site.id, creator_id=user.id)
+        slice.save()
+        self.assertTrue(slice.id > 0)
+        self.assertNotEqual(slice.site, None)
+        self.assertEqual(slice.site.id, site.id)
+
+    def test_foreign_key_set_with_invalidate(self):
+        site = self.orm.Site(name="mysite")
+        site.save()
+        self.assertTrue(site.id > 0)
+        user = self.orm.User(
+            email="fake_"
+            + "".join(
+                random.choice(string.ascii_uppercase + string.digits) for _ in range(10)
+            ),
+            site_id=site.id,
+        )
+        user.save()
+        self.assertTrue(user.id > 0)
+        slice = self.orm.Slice(name="mysite_foo", site=site, creator_id=user.id)
+        slice.save()
+        slice.invalidate_cache()
+        self.assertTrue(slice.id > 0)
+        self.assertNotEqual(slice.site, None)
+        self.assertEqual(slice.site.id, site.id)
+        if not USE_FAKE_STUB:
+            self.assertTrue(slice.id in slice.site.slices_ids)
+
+    def test_foreign_key_set_without_invalidate(self):
+        site = self.orm.Site(name="mysite")
+        site.save()
+        self.assertTrue(site.id > 0)
+        user = self.orm.User(
+            email="fake_"
+            + "".join(
+                random.choice(string.ascii_uppercase + string.digits) for _ in range(10)
+            ),
+            site_id=site.id,
+        )
+        user.save()
+        self.assertTrue(user.id > 0)
+        slice = self.orm.Slice(name="mysite_foo", site=site, creator_id=user.id)
+        slice.save()
+        self.assertTrue(slice.id > 0)
+        self.assertNotEqual(slice.site, None)
+        self.assertEqual(slice.site.id, site.id)
+        if not USE_FAKE_STUB:
+            self.assertTrue(slice.id in slice.site.slices_ids)
+            ids_from_models = [x.id for x in slice.site.slices.all()]
+            self.assertTrue(slice.id in ids_from_models)
+
+    def test_foreign_key_reset(self):
+        site = self.orm.Site(name="mysite")
+        site.save()
+        self.assertTrue(site.id > 0)
+        user = self.orm.User(
+            email="fake_"
+            + "".join(
+                random.choice(string.ascii_uppercase + string.digits) for _ in range(10)
+            ),
+            site_id=site.id,
+        )
+        user.save()
+        self.assertTrue(user.id > 0)
+        slice = self.orm.Slice(name="mysite_foo", site=site, creator_id=user.id)
+        slice.save()
+        self.assertTrue(slice.id > 0)
+        self.assertNotEqual(slice.site, None)
+        self.assertEqual(slice.site.id, site.id)
+        if not USE_FAKE_STUB:
+            self.assertTrue(slice.id in site.slices_ids)
+            self.assertTrue(slice.id in slice.site.slices_ids)
+
+        site2 = self.orm.Site(name="mysite2")
+        site2.save()
+        slice.name = "mysite2_foo"
+        slice.site = site2
+        slice.save()
+        self.assertNotEqual(slice.site, None)
+        self.assertEqual(slice.site.id, site2.id)
+        if not USE_FAKE_STUB:
+            self.assertTrue(slice.id not in site.slices_ids)
+            self.assertTrue(slice.id in site2.slices_ids)
+            self.assertTrue(slice.id in slice.site.slices_ids)
+            ids_from_models1 = [x.id for x in site.slices.all()]
+            self.assertTrue(slice.id not in ids_from_models1)
+            ids_from_models2 = [x.id for x in site2.slices.all()]
+            self.assertTrue(slice.id in ids_from_models2)
+
+    def test_foreign_key_back_and_forth_even(self):
+        site = self.orm.Site(name="mysite")
+        site.save()
+        self.assertTrue(site.id > 0)
+        user = self.orm.User(
+            email="fake_"
+            + "".join(
+                random.choice(string.ascii_uppercase + string.digits) for _ in range(10)
+            ),
+            site_id=site.id,
+        )
+        user.save()
+        self.assertTrue(user.id > 0)
+        slice = self.orm.Slice(name="mysite_foo", site=site, creator_id=user.id)
+        slice.save()
+        self.assertTrue(slice.id > 0)
+        self.assertNotEqual(slice.site, None)
+        self.assertEqual(slice.site.id, site.id)
+        if not USE_FAKE_STUB:
+            self.assertTrue(slice.id in site.slices_ids)
+            self.assertTrue(slice.id in slice.site.slices_ids)
+
+        site2 = self.orm.Site(name="mysite2")
+        site2.save()
+        slice.name = "mysite2_foo"
+        slice.site = site2
+        slice.site = site
+        slice.site = site2
+        slice.site = site
+        slice.save()
+        self.assertNotEqual(slice.site, None)
+        self.assertEqual(slice.site.id, site.id)
+        if not USE_FAKE_STUB:
+            self.assertTrue(slice.id not in site2.slices_ids)
+            self.assertTrue(slice.id in site.slices_ids)
+            self.assertTrue(slice.id in slice.site.slices_ids)
+
+    def test_foreign_key_back_and_forth_odd(self):
+        site = self.orm.Site(name="mysite")
+        site.save()
+        self.assertTrue(site.id > 0)
+        user = self.orm.User(
+            email="fake_"
+            + "".join(
+                random.choice(string.ascii_uppercase + string.digits) for _ in range(10)
+            ),
+            site_id=site.id,
+        )
+        user.save()
+        self.assertTrue(user.id > 0)
+        slice = self.orm.Slice(name="mysite_foo", site=site, creator_id=user.id)
+        slice.save()
+        self.assertTrue(slice.id > 0)
+        self.assertNotEqual(slice.site, None)
+        self.assertEqual(slice.site.id, site.id)
+        if not USE_FAKE_STUB:
+            self.assertTrue(slice.id in site.slices_ids)
+            self.assertTrue(slice.id in slice.site.slices_ids)
+
+        site2 = self.orm.Site(name="mysite2")
+        site2.save()
+        slice.name = "mysite2_foo"
+        slice.site = site2
+        slice.site = site
+        slice.site = site2
+        slice.site = site
+        slice.site = site2
+        slice.save()
+        self.assertNotEqual(slice.site, None)
+        self.assertEqual(slice.site.id, site2.id)
+        if not USE_FAKE_STUB:
+            self.assertTrue(slice.id not in site.slices_ids)
+            self.assertTrue(slice.id in site2.slices_ids)
+            self.assertTrue(slice.id in slice.site.slices_ids)
+
+    def test_foreign_key_create_null(self):
+        site = self.orm.Site(name="mysite")
+        site.save()
+        self.assertTrue(site.id > 0)
+        user = self.orm.User(
+            email="fake_"
+            + "".join(
+                random.choice(string.ascii_uppercase + string.digits) for _ in range(10)
+            ),
+            site_id=site.id,
+        )
+        user.save()
+        self.assertTrue(user.id > 0)
+        slice = self.orm.Slice(
+            name="mysite_foo", site=site, service=None, creator_id=user.id
+        )
+        slice.save()
+        slice.invalidate_cache()
+        self.assertTrue(slice.id > 0)
+        self.assertEqual(slice.service, None)
+
+    def test_foreign_key_set_null(self):
+        site = self.orm.Site(name="mysite")
+        site.save()
+        self.assertTrue(site.id > 0)
+        user = self.orm.User(
+            email="fake_"
+            + "".join(
+                random.choice(string.ascii_uppercase + string.digits) for _ in range(10)
+            ),
+            site_id=site.id,
+        )
+        user.save()
+        self.assertTrue(user.id > 0)
+        service = self.orm.Service(name="myservice")
+        service.save()
+        self.assertTrue(service.id > 0)
+        # start out slice.service is non-None
+        slice = self.orm.Slice(
+            name="mysite_foo", site=site, service=service, creator_id=user.id
+        )
+        slice.save()
+        slice.invalidate_cache()
+        self.assertTrue(slice.id > 0)
+        self.assertNotEqual(slice.service, None)
+        self.assertEqual(slice.service.id, service.id)
+        # now set it to None
+        slice.service = None
+        slice.save()
+        slice.invalidate_cache()
+        self.assertEqual(slice.service, None)
+
+    def test_generic_foreign_key_get(self):
+        service = self.orm.Service(name="myservice")
+        service.save()
+        site = self.orm.Site(name="mysite")
+        site.save()
+        self.assertTrue(site.id > 0)
+        tag = self.orm.Tag(
+            service=service,
+            name="mytag",
+            value="somevalue",
+            content_type=site.self_content_type_id,
+            object_id=site.id,
+        )
+        tag.save()
+        self.assertTrue(tag.id > 0)
+        self.assertNotEqual(tag.content_object, None)
+        self.assertEqual(tag.content_object.id, site.id)
+
+    def test_generic_foreign_key_get_decl(self):
+        service = self.orm.Service(name="myservice")
+        service.save()
+        site = self.orm.Site(name="mysite")
+        site.save()
+        self.assertTrue(site.id > 0)
+        tag = self.orm.Tag(
+            service=service,
+            name="mytag",
+            value="somevalue",
+            content_type=site.self_content_type_id + "_decl",
+            object_id=site.id,
+        )
+        tag.save()
+        self.assertTrue(tag.id > 0)
+        self.assertNotEqual(tag.content_object, None)
+        self.assertEqual(tag.content_object.id, site.id)
+
+    def test_generic_foreign_key_get_bad_contenttype(self):
+        service = self.orm.Service(name="myservice")
+        service.save()
+        site = self.orm.Site(name="mysite")
+        site.save()
+        self.assertTrue(site.id > 0)
+        tag = self.orm.Tag(
+            service=service,
+            name="mytag",
+            value="somevalue",
+            content_type="does_not_exist",
+            object_id=site.id,
+        )
+        tag.save()
+        self.assertTrue(tag.id > 0)
+        with self.assertRaises(Exception) as e:
+
+            self.assertEqual(
+                str(e.exception),
+                "Content_type does_not_exist not found in self.content_type_map",
+            )
+
+    def test_generic_foreign_key_get_bad_id(self):
+        service = self.orm.Service(name="myservice")
+        service.save()
+        site = self.orm.Site(name="mysite")
+        site.save()
+        self.assertTrue(site.id > 0)
+        tag = self.orm.Tag(
+            service=service,
+            name="mytag",
+            value="somevalue",
+            content_type=site.self_content_type_id,
+            object_id=4567,
+        )
+        tag.save()
+        self.assertTrue(tag.id > 0)
+        with self.assertRaises(Exception) as e:
+            self.assertEqual(
+                str(e.exception), "Object 4567 of model Site was not found"
+            )
+
+    def test_generic_foreign_key_set(self):
+        service = self.orm.Service(name="myservice")
+        service.save()
+        site = self.orm.Site(name="mysite")
+        site.save()
+        self.assertTrue(site.id > 0)
+        tag = self.orm.Tag(service=service, name="mytag", value="somevalue")
+        tag.content_object = site
+        tag.invalidate_cache()
+        self.assertEqual(tag.content_type, site.self_content_type_id)
+        self.assertEqual(tag.object_id, site.id)
+        tag.save()
+        self.assertTrue(tag.id > 0)
+        self.assertNotEqual(tag.content_object, None)
+        self.assertEqual(tag.content_object.id, site.id)
+
+    def test_field_null(self):
+        """ In a saved object, if a nullable field is left set to None, make sure the ORM returns None """
+
+        tm = self.orm.TestModel()
+        tm.save()
+
+        tm = self.orm.TestModel.objects.all()[0]
+        self.assertFalse(tm._wrapped_class.HasField("intfield"))
+        self.assertEqual(tm.intfield, None)
+
+    def test_field_null_new(self):
+        """ For models that haven't been saved yet, reading the field should return the gRPC default """
+
+        tm = self.orm.TestModel()
+
+        self.assertEqual(tm.intfield, 0)
+
+    def test_field_non_null(self):
+        """ In a saved object, if a nullable field is set to a value, then make sure the ORM returns the value """
+
+        tm = self.orm.TestModel(intfield=3)
+        tm.save()
+
+        tm = self.orm.TestModel.objects.all()[0]
+        self.assertEqual(tm.intfield, 3)
+
+    def test_field_set_null(self):
+        """ Setting a field to None is not allowed """
+
+        tm = self.orm.TestModel()
+        with self.assertRaises(Exception) as e:
+            tm.intfile = None
+        self.assertEqual(
+            str(e.exception),
+            "Setting a non-foreignkey field to None is not supported",
+        )
+
+    def test_deleted_objects_all(self):
+        orig_len_sites = len(self.orm.Site.objects.all())
+        orig_len_deleted_sites = len(self.orm.Site.deleted_objects.all())
+        site = self.orm.Site(name="mysite")
+        site.save()
+        site.delete()
+        sites = self.orm.Site.objects.all()
+        self.assertEqual(len(sites), orig_len_sites)
+        deleted_sites = self.orm.Site.deleted_objects.all()
+        self.assertEqual(len(deleted_sites), orig_len_deleted_sites + 1)
+
+    def test_deleted_objects_filter(self):
+        with patch.object(
+            self.orm.grpc_stub, "FilterTestModel", wraps=self.orm.grpc_stub.FilterTestModel
+        ) as filter:
+            foo = self.orm.TestModel(name="foo")
+            foo.save()
+            foo.delete()
+
+            # There should be no live objects
+            objs = self.orm.TestModel.objects.filter(name="foo")
+            self.assertEqual(len(objs), 0)
+
+            # There should be one deleted object
+            deleted_objs = self.orm.TestModel.deleted_objects.filter(name="foo")
+            self.assertEqual(len(deleted_objs), 1)
+
+            # Two calls, one for when we checked live objects, the other for when we checked deleted objects
+            self.assertEqual(filter.call_count, 2)
+            q = filter.call_args[0][0]
+
+            # Now spy on the query that was generated, to make sure it looks like we expect
+            self.assertEqual(q.kind, q.SYNCHRONIZER_DELETED_OBJECTS)
+            self.assertEqual(len(q.elements), 1)
+            self.assertEqual(q.elements[0].operator, q.elements[0].EQUAL)
+            self.assertEqual(q.elements[0].sValue, "foo")
+
+
 def main():
     global USE_FAKE_STUB
     global xos_grpc_client
