From 97730821ef43d7abf76212865b5b24007f2f7f63 Mon Sep 17 00:00:00 2001 From: Lujin Date: Fri, 16 Mar 2018 20:24:47 +0900 Subject: [PATCH] Add a test class to validate UTs fixes of new_facade flag In I3a8bc06a671e37959e3014f8672b9a5e118c5c52, we added mocks to avoid touching databases when switching to new engine facade. However, currently we do not have test codes to catch those failure. This patch adds a fake object setting new_facade to True, to validate without I3a8bc06a671e37959e3014f8672b9a5e118c5c52, the test class would fail. Change-Id: I968806b237f9c1275e7624a0995189c1d0bc75fb Closes-Bug: #1750735 --- neutron/tests/unit/objects/test_base.py | 29 +++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/neutron/tests/unit/objects/test_base.py b/neutron/tests/unit/objects/test_base.py index 9d7c97232ce..821b7f3d839 100644 --- a/neutron/tests/unit/objects/test_base.py +++ b/neutron/tests/unit/objects/test_base.py @@ -90,6 +90,30 @@ class FakeSmallNeutronObject(base.NeutronDbObject): } +@base.NeutronObjectRegistry.register_if(False) +class FakeSmallNeutronObjectNewEngineFacade(base.NeutronDbObject): + # Version 1.0: Initial version + VERSION = '1.0' + + db_model = ObjectFieldsModel + + new_facade = True + + primary_keys = ['field1'] + + foreign_keys = { + 'FakeNeutronObjectCompositePrimaryKeyWithId': {'field1': 'id'}, + 'FakeNeutronDbObject': {'field2': 'id'}, + 'FakeNeutronObjectUniqueKey': {'field3': 'id'}, + } + + fields = { + 'field1': common_types.UUIDField(), + 'field2': common_types.UUIDField(), + 'field3': common_types.UUIDField(), + } + + @base.NeutronObjectRegistry.register_if(False) class FakeSmallNeutronObjectWithMultipleParents(base.NeutronDbObject): # Version 1.0: Initial version @@ -1255,6 +1279,11 @@ class BaseDbObjectNonStandardPrimaryKeyTestCase(BaseObjectIfaceTestCase): _test_class = FakeNeutronObjectNonStandardPrimaryKey +class BaseDbObjectNewEngineFacade(BaseObjectIfaceTestCase): + + _test_class = FakeSmallNeutronObjectNewEngineFacade + + class BaseDbObjectCompositePrimaryKeyTestCase(BaseObjectIfaceTestCase): _test_class = FakeNeutronObjectCompositePrimaryKey