Merge "Module to manage pip packages"
[yardstick.git] / yardstick / 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 import create_image
13 from yardstick.common import openstack_utils
14
15 # NOTE(elfoley): There should be more tests here.
16 class CreateImageTestCase(unittest.TestCase):
17
18     @mock.patch.object(openstack_utils, 'create_image')
19     @mock.patch.object(openstack_utils, 'get_glance_client')
20     def test_create_image(self, mock_get_glance_client, mock_create_image):
21         options = {
22             'image_name': 'yardstick_test_image_01',
23             'disk_format': 'qcow2',
24             'container_format': 'bare',
25             'min_disk': '1',
26             'min_ram': '512',
27             'protected': 'False',
28             'tags': '["yardstick automatic test image"]',
29             'file_path': '/home/opnfv/images/cirros-0.3.5-x86_64-disk.img'
30         }
31         args = {"options": options}
32         obj = create_image.CreateImage(args, {})
33         obj.run({})
34         mock_create_image.assert_called_once()
35         mock_get_glance_client.assert_called_once()
36
37
38 def main():
39     unittest.main()
40
41
42 if __name__ == '__main__':
43     main()