~ubuntu-branches/ubuntu/trusty/cinder/trusty

« back to all changes in this revision

Viewing changes to cinder/tests/test_coraid.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2013-03-25 08:30:42 UTC
  • mfrom: (10.1.1 raring-proposed)
  • Revision ID: package-import@ubuntu.com-20130325083042-4c9f80w7t98klicf
Tags: 1:2013.1~rc2-0ubuntu2
debian/rules: Fix FTBFS, we want '-v' and not '-V'. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
from cinder.volume import configuration as conf
24
24
from cinder.volume.drivers import coraid
25
25
from cinder.volume.drivers.coraid import CoraidDriver
 
26
from cinder.volume.drivers.coraid import CoraidESMException
26
27
from cinder.volume.drivers.coraid import CoraidRESTClient
27
28
 
28
29
import cookielib
32
33
 
33
34
 
34
35
fake_esm_ipaddress = "192.168.0.1"
35
 
fake_esm_username = "admin"
 
36
fake_esm_username = "darmok"
 
37
fake_esm_group = "tanagra"
36
38
fake_esm_password = "12345678"
37
39
 
38
40
fake_volume_name = "volume-12345678-1234-1234-1234-1234567890ab"
87
89
                    "metaCROp": "noAction",
88
90
                    "message": None}
89
91
 
 
92
fake_group_fullpath = "admin group:%s" % (fake_esm_group)
 
93
fake_group_id = 4
 
94
fake_login_reply = {"values": [
 
95
                    {"fullPath": fake_group_fullpath,
 
96
                     "groupId": fake_group_id}],
 
97
                    "message": "",
 
98
                    "state": "adminSucceed",
 
99
                    "metaCROp": "noAction"}
 
100
 
 
101
fake_group_fail_fullpath = "fail group:%s" % (fake_esm_group)
 
102
fake_group_fail_id = 5
 
103
fake_login_reply_group_fail = {"values": [
 
104
                               {"fullPath": fake_group_fail_fullpath,
 
105
                                "groupId": fake_group_fail_id}],
 
106
                               "message": "",
 
107
                               "state": "adminSucceed",
 
108
                               "metaCROp": "noAction"}
 
109
 
90
110
 
91
111
class TestCoraidDriver(test.TestCase):
92
112
    def setUp(self):
98
118
        configuration.append_config_values(mox.IgnoreArg())
99
119
        configuration.coraid_esm_address = fake_esm_ipaddress
100
120
        configuration.coraid_user = fake_esm_username
 
121
        configuration.coraid_group = fake_esm_group
101
122
        configuration.coraid_password = fake_esm_password
102
123
 
103
124
        self.drv = CoraidDriver(configuration=configuration)
149
170
                       lambda *_, **__: self.rest_mock)
150
171
        self.drv = CoraidRESTClient(fake_esm_ipaddress,
151
172
                                    fake_esm_username,
 
173
                                    fake_esm_group,
152
174
                                    fake_esm_password)
153
175
 
 
176
    def test__get_group_id(self):
 
177
        setattr(self.rest_mock, '_get_group_id',
 
178
                lambda *_: True)
 
179
        self.assertEquals(self.drv._get_group_id(fake_esm_group,
 
180
                                                 fake_login_reply),
 
181
                          fake_group_id)
 
182
 
 
183
    def test__set_group(self):
 
184
        setattr(self.rest_mock, '_set_group',
 
185
                lambda *_: fake_group_id)
 
186
        self.stubs.Set(CoraidRESTClient, '_esm',
 
187
                       lambda *_: fake_login_reply)
 
188
        self.drv._set_group(fake_login_reply)
 
189
 
 
190
    def test__set_group_fails_no_group(self):
 
191
        setattr(self.rest_mock, '_set_group',
 
192
                lambda *_: False)
 
193
        self.stubs.Set(CoraidRESTClient, '_esm',
 
194
                       lambda *_: fake_login_reply_group_fail)
 
195
        self.assertRaises(CoraidESMException,
 
196
                          self.drv._set_group,
 
197
                          fake_login_reply_group_fail)
 
198
 
154
199
    def test__configure(self):
155
200
        setattr(self.rest_mock, '_configure',
156
201
                lambda *_: True)