1 # Copyright (c) 2018 Intel Corporation
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
7 # http://www.apache.org/licenses/LICENSE-2.0
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.
18 from yardstick.network_services.traffic_profile import prox_irq
21 class TestProxIrqProfile(unittest.TestCase):
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)
28 def _stop_mocks(self):
29 self._mock_log_info.stop()
31 def test_execute_1(self):
37 traffic_generator = mock.MagicMock()
38 attrs1 = {'get.return_value' : 10}
39 traffic_generator.scenario_helper.all_options.configure_mock(**attrs1)
41 attrs2 = {'__getitem__.return_value' : 10, 'get.return_value': 10}
42 traffic_generator.scenario_helper.scenario_cfg["runner"].configure_mock(**attrs2)
44 profile_helper = mock.MagicMock()
46 profile = prox_irq.ProxIrqProfile(tp_config)
47 profile.init(mock.MagicMock())
48 profile._profile_helper = profile_helper
50 profile.execute_traffic(traffic_generator)
52 is_ended_flag = profile.is_ended()
54 self.assertFalse(is_ended_flag)
55 self.assertEqual(profile.lower_bound, 10.0)