def test_list_backup(self): backups = db.backup_get_all_by_project(self.ctxt, 'project1') self.assertEqual(0, len(backups)) b2 = self._create_backup_db_entry(project_id='project1') backups = db.backup_get_all_by_project(self.ctxt, 'project1') self.assertEqual(1, len(backups)) self.assertEqual(b2, backups[0].id)
def test_list_backup(self): backups = db.backup_get_all_by_project(self.ctxt, 'project1') self.assertEqual(len(backups), 0) b1 = self._create_backup_db_entry() b2 = self._create_backup_db_entry(project_id='project1') backups = db.backup_get_all_by_project(self.ctxt, 'project1') self.assertEqual(len(backups), 1) self.assertEqual(backups[0].id, b2)
def get_all_by_project( cls, context, project_id, filters=None, marker=None, limit=None, offset=None, sort_keys=None, sort_dirs=None ): backups = db.backup_get_all_by_project( context, project_id, filters, marker, limit, offset, sort_keys, sort_dirs ) return base.obj_make_list(context, cls(context), objects.Backup, backups)
def test_backup_get_all_by_project_with_deleted(self): """Test deleted backups don't show up in backup_get_all_by_project. Unless context.read_deleted is 'yes'""" backups = db.backup_get_all_by_project(self.ctxt, 'fake') self.assertEqual(len(backups), 0) backup_id_keep = self._create_backup_db_entry() backup_id = self._create_backup_db_entry() db.backup_destroy(self.ctxt, backup_id) backups = db.backup_get_all_by_project(self.ctxt, 'fake') self.assertEqual(len(backups), 1) self.assertEqual(backups[0].id, backup_id_keep) ctxt_read_deleted = context.get_admin_context('yes') backups = db.backup_get_all_by_project(ctxt_read_deleted, 'fake') self.assertEqual(len(backups), 2)
def get_all_by_project(cls, context, project_id, filters=None, marker=None, limit=None, offset=None, sort_keys=None, sort_dirs=None): backups = db.backup_get_all_by_project(context, project_id, filters, marker, limit, offset, sort_keys, sort_dirs) return base.obj_make_list(context, cls(context), objects.Backup, backups)
def test_backup_get_all_by_project_with_deleted(self): """Test deleted backups. Test deleted backups don't show up in backup_get_all_by_project. Unless context.read_deleted is 'yes'. """ backups = db.backup_get_all_by_project(self.ctxt, "fake") self.assertEqual(0, len(backups)) backup_keep = self._create_backup_db_entry() backup = self._create_backup_db_entry() db.backup_destroy(self.ctxt, backup.id) backups = db.backup_get_all_by_project(self.ctxt, "fake") self.assertEqual(1, len(backups)) self.assertEqual(backup_keep.id, backups[0].id) ctxt_read_deleted = context.get_admin_context("yes") backups = db.backup_get_all_by_project(ctxt_read_deleted, "fake") self.assertEqual(2, len(backups))
def get_all_by_project(cls, context, project_id, filters=None): backups = db.backup_get_all_by_project(context, project_id, filters) return base.obj_make_list(context, cls(context), objects.Backup, backups)
def test_backup_get_all_by_project(self): byproj = db.backup_get_all_by_project(self.ctxt, self.created[1]['project_id']) self._assertEqualObjects(self.created[1], byproj[0])