1# Copyright (C) 2013 Hewlett-Packard Development Company, L.P.
2# All Rights Reserved.
3#
4#    Licensed under the Apache License, Version 2.0 (the "License"); you may
5#    not use this file except in compliance with the License. You may obtain
6#    a copy of the License at
7#
8#         http://www.apache.org/licenses/LICENSE-2.0
9#
10#    Unless required by applicable law or agreed to in writing, software
11#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13#    License for the specific language governing permissions and limitations
14#    under the License.
15
16from cinderclient.tests.unit import utils
17from cinderclient.tests.unit.v2 import fakes
18
19
20cs = fakes.FakeClient()
21
22
23class VolumeTransfersTest(utils.TestCase):
24
25    def test_create(self):
26        vol = cs.transfers.create('1234')
27        cs.assert_called('POST', '/os-volume-transfer')
28        self._assert_request_id(vol)
29
30    def test_get(self):
31        transfer_id = '5678'
32        vol = cs.transfers.get(transfer_id)
33        cs.assert_called('GET', '/os-volume-transfer/%s' % transfer_id)
34        self._assert_request_id(vol)
35
36    def test_list(self):
37        lst = cs.transfers.list()
38        cs.assert_called('GET', '/os-volume-transfer/detail')
39        self._assert_request_id(lst)
40
41    def test_delete(self):
42        b = cs.transfers.list()[0]
43        vol = b.delete()
44        cs.assert_called('DELETE', '/os-volume-transfer/5678')
45        self._assert_request_id(vol)
46        vol = cs.transfers.delete('5678')
47        self._assert_request_id(vol)
48        cs.assert_called('DELETE', '/os-volume-transfer/5678')
49        vol = cs.transfers.delete(b)
50        cs.assert_called('DELETE', '/os-volume-transfer/5678')
51        self._assert_request_id(vol)
52
53    def test_accept(self):
54        transfer_id = '5678'
55        auth_key = '12345'
56        vol = cs.transfers.accept(transfer_id, auth_key)
57        cs.assert_called('POST', '/os-volume-transfer/%s/accept' % transfer_id)
58        self._assert_request_id(vol)
59