Merge "Sync up 'install.yaml' with 'nsb_setup.yml'"
[yardstick.git] / yardstick / tests / unit / network_services / traffic_profile / test_prox_irq.py
1 # Copyright (c) 2018 Intel Corporation
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #      http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 import unittest
16 import mock
17
18 from yardstick.network_services.traffic_profile import prox_irq
19
20
21 class TestProxIrqProfile(unittest.TestCase):
22
23     def setUp(self):
24         self._mock_log_info = mock.patch.object(prox_irq.LOG, 'info')
25         self.mock_log_info = self._mock_log_info.start()
26         self.addCleanup(self._stop_mocks)
27
28     def _stop_mocks(self):
29         self._mock_log_info.stop()
30
31     def test_execute_1(self):
32         tp_config = {
33             'traffic_profile': {
34             },
35         }
36
37         traffic_generator = mock.MagicMock()
38         attrs1 = {'get.return_value' : 10}
39         traffic_generator.scenario_helper.all_options.configure_mock(**attrs1)
40
41         attrs2 = {'__getitem__.return_value' : 10, 'get.return_value': 10}
42         traffic_generator.scenario_helper.scenario_cfg["runner"].configure_mock(**attrs2)
43
44         profile_helper = mock.MagicMock()
45
46         profile = prox_irq.ProxIrqProfile(tp_config)
47         profile.init(mock.MagicMock())
48         profile._profile_helper = profile_helper
49
50         profile.execute_traffic(traffic_generator)
51         profile.run_test()
52         is_ended_flag = profile.is_ended()
53
54         self.assertFalse(is_ended_flag)
55         self.assertEqual(profile.lower_bound, 10.0)