Пример #1
0
 def test_filtered_backups(self):
     vol1 = self.create_volume('ACTIVE')
     vol2 = self.create_volume('ACTIVE')
     # vol1/backup1
     req = Request.blank('?%s' % urlencode({'volume': vol1.id}))
     c = Controller({'id': 'backup1', 'account_id': self.account.id},
                    self.mock_app)
     resp = c.create(req)
     # vol2/backup2
     req = Request.blank('?%s' % urlencode({'volume': vol2.id}))
     c = Controller({'id': 'backup2', 'account_id': self.account.id},
                    self.mock_app)
     resp = c.create(req)
     # vol1/backup3
     req = Request.blank('?%s' % urlencode({'volume': vol1.id}))
     c = Controller({'id': 'backup3', 'account_id': self.account.id},
                    self.mock_app)
     resp = c.create(req)
     # un-filtered backups
     req = Request.blank('')
     resp = c.index(req)
     self.assertEquals(len(resp.body), 3)
     # filter backups for vol2 (should just be backup2)
     req = Request.blank('?volume_id=%s' % vol2.id)
     resp = c.index(req)
     self.assertEquals(len(resp.body), 1)
     backup2 = resp.body[0]
     self.assertEquals(backup2['volume_id'], vol2.id)
     # filter backups for vol1 (should have backup1 & backup3)
     req = Request.blank('?volume_id=%s' % vol1.id)
     resp = c.index(req)
     self.assertEquals(len(resp.body), 2)
     for backup in resp.body:
         self.assertEquals(backup['volume_id'], vol1.id)
Пример #2
0
 def test_list_populated_backups(self):
     # create a volume directly in the db
     volume = self.create_volume('ACTIVE')
     # use the api to create a few backups
     for i in range(3):
         backup_id = 'backup%s' % i
         c = Controller({
             'account_id': self.account.id,
             'id': backup_id
         }, self.mock_app)
         params = {
             'volume': volume.id,
         }
         req = Request.blank('?%s' % urlencode(params))
         resp = c.create(req)
         self.assertEqual(resp.body['id'], backup_id)
         self.assertEquals(resp.body['volume_id'], volume.id)
         self.assertEquals(resp.body['status'], 'SAVING')
     # get the index/listing of the newly created backups
     c = Controller({'account_id': self.account.id}, self.mock_app)
     req = Request.blank('')
     resp = c.index(req)
     # make sure everything looks to be there
     self.assertEquals(len(resp.body), 3)
     for backup in resp.body:
         self.assert_(backup['id'].startswith('backup'))
Пример #3
0
 def test_list_populated_backups(self):
     # create a volume directly in the db
     volume = self.create_volume('ACTIVE')
     # use the api to create a few backups
     for i in range(3):
         backup_id = 'backup%s' % i
         c = Controller({'account_id': self.account.id, 'id': backup_id},
                        self.mock_app)
         params = {
             'volume': volume.id,
         }
         req = Request.blank('?%s' % urlencode(params))
         resp = c.create(req)
         self.assertEqual(resp.body['id'], backup_id)
         self.assertEquals(resp.body['volume_id'], volume.id)
         self.assertEquals(resp.body['status'], 'SAVING')
     # get the index/listing of the newly created backups
     c = Controller({'account_id': self.account.id}, self.mock_app)
     req = Request.blank('')
     resp = c.index(req)
     # make sure everything looks to be there
     self.assertEquals(len(resp.body), 3)
     for backup in resp.body:
         self.assert_(backup['id'].startswith('backup'))
Пример #4
0
 def test_list_empty_backups(self):
     # create controller
     c = Controller({'account_id': self.account.id}, self.mock_app)
     req = Request.blank('')
     resp = c.index(req)
     self.assertEquals(len(resp.body), 0)