Debian Codegraph @

seamicroclient/tests/functional/v2/test_volumes.py

raw
1 # -*- coding: utf-8 -*-
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License"); you may
4 # not use this file except in compliance with the License. You may obtain
5 # a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12 # License for the specific language governing permissions and limitations
13 # under the License.
14 from seamicroclient.tests import utils
15 from seamicroclient.v2 import Client
16
17
18 cs = Client("admin", "seamicro", "http://chassis/v2.0")
19
20
21 class VolumesTest(utils.TestCase):
22
23 @staticmethod
24 def create_volume(volume_size=2, pool=None):
25 return cs.volumes.create(volume_size, pool)
26
27 def test_list_volume(self):
28 volume_list = cs.volumes.list()
29 self.assertTrue(len(volume_list) > 0)
30
31 def test_get_volume(self):
32 volume_id = cs.volumes.list()[0].id
33 volume = cs.volumes.get(volume_id)
34 self.assertEqual(volume.id, volume_id)
35
36 def test_create_volume(self):
37 pool = cs.pools.list()[0]
38 volume_size = 2
39 volume_id = self.create_volume(volume_size, pool)
40 self.assertIn(pool.id, volume_id)
41 cs.volumes.delete(volume_id)
42
43 def test_delete_volume(self):
44 pool = cs.pools.list()[0]
45 volume = self.create_volume(pool=pool)
46 cs.volumes.delete(volume)
47 volume = cs.volumes.get(volume)
48 self.assertEqual(volume.actualSize, 0)