def test_serialize_init_pinned_has_manifest(self): """Test that pinned to older version we have manifest.""" objs_version = '1.5' serializer = objects.base.CinderObjectSerializer(objs_version) # Serializer should have the right manifest self.assertDictEqual(fake_objects.MyHistory()[objs_version], serializer.manifest)
def test_dict_objects(self): obj = self.TestDictObject() self.assertNotIn('non_existing', obj) self.assertEqual('val', obj.get('abc', 'val')) self.assertNotIn('abc', obj) obj.abc = 'val2' self.assertEqual('val2', obj.get('abc', 'val')) self.assertEqual(42, obj.get('foo')) self.assertEqual(42, obj.get('foo', None)) self.assertIn('foo', obj) self.assertIn('abc', obj) self.assertNotIn('def', obj) @mock.patch('cinder.objects.base.OBJ_VERSIONS', fake_objects.MyHistory()) class TestCinderObjectSerializer(test_objects.BaseObjectsTestCase): BACKPORT_MSG = ('Backporting %(obj_name)s from version %(src_vers)s to ' 'version %(dst_vers)s') def setUp(self): super(TestCinderObjectSerializer, self).setUp() self.obj = fake_objects.ChildObject(scheduled_at=None, uuid=uuid.uuid4(), text='text', integer=1) self.parent = fake_objects.ParentObject(uuid=uuid.uuid4(), child=self.obj, scheduled_at=None) self.parent_list = fake_objects.ParentObjectList(objects=[self.parent])