1
# -*- coding: utf-8 -*-
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
7
# http://www.apache.org/licenses/LICENSE-2.0
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
14
from seamicroclient.tests import utils
15
from seamicroclient.v2 import Client
18
cs = Client("admin", "seamicro", "http://chassis/v2.0")
21
class VolumesTest(utils.TestCase):
24
def create_volume(volume_size=2, pool=None):
25
return cs.volumes.create(volume_size, pool)
27
def test_list_volume(self):
28
volume_list = cs.volumes.list()
29
self.assertTrue(len(volume_list) > 0)
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)
36
def test_create_volume(self):
37
pool = cs.pools.list()[0]
39
volume_id = self.create_volume(volume_size, pool)
40
self.assertIn(pool.id, volume_id)
41
cs.volumes.delete(volume_id)
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)