def backup_get_all_by_project(context, project_id):
authorize_project_context(context, project_id)
- return model_query(context, models.Backup, read_deleted="yes").all()
+ return model_query(context, models.Backup, read_deleted="yes").\
+ filter_by(project_id=project_id).all()
@require_context
container='volumebackups',
status='creating',
size=0,
- object_count=0):
+ object_count=0,
+ project_id='fake'):
"""
Create a backup entry in the DB.
Return the entry ID
backup = {}
backup['volume_id'] = volume_id
backup['user_id'] = 'fake'
- backup['project_id'] = 'fake'
+ backup['project_id'] = project_id
backup['host'] = 'testhost'
backup['availability_zone'] = '1'
backup['display_name'] = display_name
db.backup_get,
self.ctxt,
backup_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)