示例#1
0
 def test_show(self):
     c = Controller({}, self.mock_app)
     req = Request.blank('?name=test')
     name = c.create(req).body['name']
     c = Controller({'name': 'NoVolumeType'}, self.mock_app)
     req = Request.blank('')
     self.assertRaises(HTTPNotFound, c.show, req)
     c = Controller({'name': 'test'}, self.mock_app)
     req = Request.blank('')
     res = c.show(req)
     self.assertEqual(res.body['name'], 'test')
示例#2
0
 def test_delete(self):
     c = Controller({}, self.mock_app)
     req = Request.blank('?name=test')
     name = c.create(req).body['name']
     c = Controller({'name': 'NoVolumeType'}, self.mock_app)
     req = Request.blank('')
     self.assertRaises(HTTPNotFound, c.delete, req)
     c = Controller({'name': name}, self.mock_app)
     req = Request.blank('')
     res = c.delete(req)
     self.assertEqual(res.body['name'], name)
     self.assertEqual(res.body['status'], 'DELETED')
示例#3
0
 def test_update(self):
     c = Controller({}, self.mock_app)
     req = Request.blank('?name=test')
     res = c.create(req)
     name = res.body['name']
     c = Controller({'name': 'NotVolumeType'}, self.mock_app)
     req = Request.blank('')
     self.assertRaises(HTTPNotFound, c.update, req)
     c = Controller({'name': name}, self.mock_app)
     req = Request.blank('?status=change')
     res = c.update(req)
     self.assertEqual(res.body['name'], name)
     self.assertEqual(res.body['status'], 'change')
示例#4
0
 def test_create_min_max(self):
     c = Controller({}, self.mock_app)
     req = Request.blank('?name=test&min_size=42&max_size=200')
     res = c.create(req)
     self.assertEqual(res.body['name'], 'test')
     self.assertEqual(res.body['min_size'], 42)
     self.assertEqual(res.body['max_size'], 200)
示例#5
0
 def test_create(self):
     c = Controller({}, self.mock_app)
     req = Request.blank('?name=test')
     res = c.create(req)
     self.assertEqual(res.body['name'], 'test')
     req = Request.blank('?name=test')
     res = c.create(req)
     self.assertEqual(res.body['name'], 'test')
示例#6
0
 def test_create_limits(self):
     c = Controller({}, self.mock_app)
     req = Request.blank('?name=test')
     res = c.create(req)
     self.assertEqual(res.body['name'], 'test')
     self.assertEqual(res.body['read_iops'], 0)
     self.assertEqual(res.body['write_iops'], 0)
     req = Request.blank('?name=test&read_iops=100&write_iops=150')
     res = c.create(req)
     self.assertEqual(res.body['name'], 'test')
     self.assertEqual(res.body['read_iops'], 100)
     self.assertEqual(res.body['write_iops'], 150)
     req = Request.blank('?name=test&read_iops=asdf&write_iops=150')
     self.assertRaises(HTTPPreconditionFailed, c.create, req)
     req = Request.blank('?name=test&read_iops=-42&write_iops=150')
     self.assertRaises(HTTPPreconditionFailed, c.create, req)
示例#7
0
 def test_index(self):
     c = Controller({}, self.mock_app)
     req = Request.blank('')
     res = c.index(req)
     self.assertEqual(res.body, [])
     req = Request.blank('?name=test')
     res = c.create(req)
     req = Request.blank('?name=test2')
     res = c.create(req)
     req = Request.blank('')
     res = c.index(req)
     self.assertEqual(len(res.body), 2)
     req = Request.blank('?name=test2')
     res = c.index(req)
     self.assertEqual(len(res.body), 1)
     self.assertEqual(res.body[0]['name'], 'test2')