blob: 83eef5278001b646c7d738d78d1bc7acb21bc949 [file] [log] [blame]
rajalakshmi-ganesanddd9e0e2012-03-21 00:49:22 +05301from nose.plugins.attrib import attr
2import unittest2 as unittest
3from tempest import openstack
4from tempest.common.utils.data_utils import rand_name
5from tempest import exceptions
6
7
8class VolumesTest(unittest.TestCase):
9
10 @classmethod
11 def setUpClass(cls):
12 cls.os = openstack.Manager()
13 cls.client = cls.os.volumes_client
14
15 @attr(type='negative')
16 def test_volume_get_nonexistant_volume_id(self):
17 """Negative: Should not be able to get details of nonexistant volume"""
18 #Creating a nonexistant volume id
19 volume_id_list = list()
20 resp, body = self.client.list_volumes()
21 for i in range(len(body)):
22 volume_id_list.append(body[i]['id'])
23 while True:
24 non_exist_id = rand_name('999')
25 if non_exist_id not in volume_id_list:
26 break
27 #Trying to GET a non existant volume
28 try:
29 resp, body = self.client.get_volume(non_exist_id)
30 except exceptions.NotFound:
31 pass
32 else:
33 self.fail('Should not be able to GET the details from a '
34 'nonexistant volume')
35
36 @attr(type='negative')
37 def test_volume_delete_nonexistant_volume_id(self):
38 """Negative: Should not be able to delete nonexistant Volume"""
39 #Creating nonexistant volume id
40 volume_id_list = list()
41 resp, body = self.client.list_volumes()
42 for i in range(len(body)):
43 volume_id_list.append(body[i]['id'])
44 while True:
45 non_exist_id = rand_name('999')
46 if non_exist_id not in volume_id_list:
47 break
48 #Trying to DELETE a non existant volume
49 try:
50 resp, body = self.client.delete_volume(non_exist_id)
51 except exceptions.NotFound:
52 pass
53 else:
54 self.fail('Should not be able to DELETE a nonexistant volume')