code inspection fixes: test_pktgen
[yardstick.git] / tests / unit / benchmark / scenarios / lib / test_create_volume.py
1 ##############################################################################
2 # Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
3 #
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
9 import unittest
10 import mock
11
12 from yardstick.benchmark.scenarios.lib.create_volume import CreateVolume
13
14
15 class CreateVolumeTestCase(unittest.TestCase):
16
17     @mock.patch('yardstick.common.openstack_utils.create_volume')
18     @mock.patch('yardstick.common.openstack_utils.get_image_id')
19     @mock.patch('yardstick.common.openstack_utils.get_cinder_client')
20     @mock.patch('yardstick.common.openstack_utils.get_glance_client')
21     def test_create_volume(self, mock_get_glance_client, mock_get_cinder_client, mock_image_id, mock_create_volume):
22         options = {
23                 'volume_name': 'yardstick_test_volume_01',
24                 'size': '256',
25                 'image': 'cirros-0.3.5'
26         }
27         args = {"options": options}
28         obj = CreateVolume(args, {})
29         obj.run({})
30         self.assertTrue(mock_create_volume.called)
31         self.assertTrue(mock_image_id.called)
32         self.assertTrue(mock_get_glance_client.called)
33         self.assertTrue(mock_get_cinder_client.called)
34
35 def main():
36     unittest.main()
37
38
39 if __name__ == '__main__':
40     main()