blob: aef99ee94b23d7726bd3e4c4d0c58dcb320fce7b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
##############################################################################
# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
#
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
from oslo_utils import uuidutils
import unittest
import mock
import yardstick.common.openstack_utils as op_utils
from yardstick.benchmark.scenarios.lib import delete_network
class DeleteNetworkTestCase(unittest.TestCase):
def setUp(self):
self._mock_delete_neutron_net = mock.patch.object(
op_utils, 'delete_neutron_net')
self.mock_delete_neutron_net = self._mock_delete_neutron_net.start()
self._mock_get_shade_client = mock.patch.object(
op_utils, 'get_shade_client')
self.mock_get_shade_client = self._mock_get_shade_client.start()
self._mock_log = mock.patch.object(delete_network, 'LOG')
self.mock_log = self._mock_log.start()
_uuid = uuidutils.generate_uuid()
self.args = {'options': {'network_id': _uuid}}
self._del_obj = delete_network.DeleteNetwork(self.args, mock.ANY)
self.addCleanup(self._stop_mock)
def _stop_mock(self):
self._mock_delete_neutron_net.stop()
self._mock_get_shade_client.stop()
self._mock_log.stop()
def test_run(self):
self.mock_delete_neutron_net.return_value = True
self.assertTrue(self._del_obj.run({}))
self.mock_log.info.assert_called_once_with(
"Delete network successful!")
def test_run_fail(self):
self.mock_delete_neutron_net.return_value = False
self.assertFalse(self._del_obj.run({}))
self.mock_log.error.assert_called_once_with("Delete network failed!")
|