Merge "Add common openstack opertation scenarios: network"
[yardstick.git] / tests / unit / benchmark / scenarios / lib / test_create_image.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_image import CreateImage
13
14
15 class CreateImageTestCase(unittest.TestCase):
16
17     @mock.patch('yardstick.common.openstack_utils.create_image')
18     @mock.patch('yardstick.common.openstack_utils.get_glance_client')
19     def test_create_image(self, mock_get_glance_client, mock_create_image):
20         options = {
21                 'image_name': 'yardstick_test_image_01',
22                 'disk_format': 'qcow2',
23                 'container_format': 'bare',
24                 'min_disk': '1',
25                 'min_ram': '512',
26                 'protected': 'False',
27                 'tags': '["yardstick automatic test image"]',
28                 'file_path': '/home/opnfv/images/cirros-0.3.5-x86_64-disk.img'
29         }
30         args = {"options": options}
31         obj = CreateImage(args, {})
32         obj.run({})
33         self.assertTrue(mock_create_image.called)
34
35
36 def main():
37     unittest.main()
38
39
40 if __name__ == '__main__':
41     main()