Merge "[docs] Documentation for BNG PPPoE RFC2544 test cases"
[yardstick.git] / yardstick / tests / unit / network_services / traffic_profile / test_prox_irq.py
1 # Copyright (c) 2018-2019 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 import time
15
16 import unittest
17 import mock
18
19 from yardstick.network_services.traffic_profile import prox_irq
20
21
22 class TestProxIrqProfile(unittest.TestCase):
23
24     def setUp(self):
25         self._mock_log_info = mock.patch.object(prox_irq.LOG, 'info')
26         self.mock_log_info = self._mock_log_info.start()
27         self.addCleanup(self._stop_mocks)
28
29     def _stop_mocks(self):
30         self._mock_log_info.stop()
31
32     @mock.patch.object(time, 'sleep')
33     def test_execute_1(self, *args):
34         tp_config = {
35             'traffic_profile': {
36             },
37         }
38
39         traffic_generator = mock.MagicMock()
40         attrs1 = {'get.return_value' : 10}
41         traffic_generator.scenario_helper.all_options.configure_mock(**attrs1)
42
43         attrs2 = {'__getitem__.return_value' : 10, 'get.return_value': 10}
44         traffic_generator.scenario_helper.scenario_cfg["runner"].configure_mock(**attrs2)
45
46         profile_helper = mock.MagicMock()
47
48         profile = prox_irq.ProxIrqProfile(tp_config)
49         profile.init(mock.MagicMock())
50         profile._profile_helper = profile_helper
51
52         profile.execute_traffic(traffic_generator)
53         profile.run_test()
54         is_ended_flag = profile.is_ended()
55
56         self.assertFalse(is_ended_flag)
57         self.assertEqual(profile.lower_bound, 10.0)