b7f29dfe4c27c61f00b328cc451e3253204d52fb
[yardstick.git] / yardstick / tests / unit / benchmark / scenarios / lib / test_create_subnet.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_subnet import CreateSubnet
13
14
15 class CreateSubnetTestCase(unittest.TestCase):
16
17     @mock.patch('yardstick.common.openstack_utils.get_neutron_client')
18     @mock.patch('yardstick.common.openstack_utils.create_neutron_subnet')
19     def test_create_subnet(self, mock_get_neutron_client, mock_create_neutron_subnet):
20         options = {
21             'openstack_paras': {
22                 'network_id': '123-123-123',
23                 'name': 'yardstick_subnet',
24                 'cidr': '10.10.10.0/24',
25                 'ip_version': '4'
26             }
27         }
28         args = {"options": options}
29         obj = CreateSubnet(args, {})
30         obj.run({})
31         self.assertTrue(mock_get_neutron_client.called)
32         self.assertTrue(mock_create_neutron_subnet.called)
33
34
35 def main():
36     unittest.main()
37
38
39 if __name__ == '__main__':
40     main()