def test_obj_make_list(self): class MyList(base.ObjectListBase, base.MasakariObject): fields = { 'objects': fields.ListOfObjectsField('MyObj'), } db_objs = [ { 'foo': 1, 'bar': 'baz', 'missing': 'banana' }, { 'foo': 2, 'bar': 'bat', 'missing': 'apple' }, ] mylist = base.obj_make_list('ctxt', MyList(), MyObj, db_objs) self.assertEqual(2, len(mylist)) self.assertEqual('ctxt', mylist._context) for index, item in enumerate(mylist): self.assertEqual(db_objs[index]['foo'], item.foo) self.assertEqual(db_objs[index]['bar'], item.bar) self.assertEqual(db_objs[index]['missing'], item.missing)
def get_all(cls, context, filters=None, sort_keys=None, sort_dirs=None, limit=None, marker=None): groups = db.host_get_all_by_filters(context, filters=filters, sort_keys=sort_keys, sort_dirs=sort_dirs, limit=limit, marker=marker) return base.obj_make_list(context, cls(context), objects.Host, groups)
def get_all(cls, ctxt, filters=None, sort_keys=None, sort_dirs=None, limit=None, marker=None): groups = db.failover_segment_get_all_by_filters(ctxt, filters=filters, sort_keys=sort_keys, sort_dirs=sort_dirs, limit=limit, marker=marker) return base.obj_make_list(ctxt, cls(ctxt), objects.FailoverSegment, groups)
def get_all(cls, ctxt, filters=None, sort_keys=None, sort_dirs=None, limit=None, marker=None): groups = db.failover_segment_get_all_by_filters(ctxt, filters=filters, sort_keys=sort_keys, sort_dirs=sort_dirs, limit=limit, marker=marker) return base.obj_make_list(ctxt, cls(ctxt), objects.FailoverSegment, groups)
def get_all(cls, context, filters=None, sort_keys=None, sort_dirs=None, limit=None, marker=None): groups = db.notifications_get_all_by_filters(context, filters=filters, sort_keys=sort_keys, sort_dirs=sort_dirs, limit=limit, marker=marker ) return base.obj_make_list(context, cls(context), objects.Notification, groups)
def test_obj_make_list(self): class MyList(base.ObjectListBase, base.MasakariObject): fields = { 'objects': fields.ListOfObjectsField('MyObj'), } db_objs = [{'foo': 1, 'bar': 'baz', 'missing': 'banana'}, {'foo': 2, 'bar': 'bat', 'missing': 'apple'}, ] mylist = base.obj_make_list('ctxt', MyList(), MyObj, db_objs) self.assertEqual(2, len(mylist)) self.assertEqual('ctxt', mylist._context) for index, item in enumerate(mylist): self.assertEqual(db_objs[index]['foo'], item.foo) self.assertEqual(db_objs[index]['bar'], item.bar) self.assertEqual(db_objs[index]['missing'], item.missing)