add yardstick iruya 9.0.0 release notes
[yardstick.git] / yardstick / tests / unit / network_services / traffic_profile / test_sip.py
1 # Copyright (c) 2019 Viosoft 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 sip
19
20
21 class TestSipProfile(unittest.TestCase):
22
23     TRAFFIC_PROFILE = {
24         "schema": "nsb:traffic_profile:0.1",
25         "name": "sip",
26         "description": "Traffic profile to run sip",
27         "traffic_profile": {
28             "traffic_type": "SipProfile",
29             "frame_rate": 100,  # pps
30             "duration": 10,
31             "enable_latency": False}}
32
33     def setUp(self):
34         self.sip_profile = sip.SipProfile(self.TRAFFIC_PROFILE)
35
36     def test___init__(self):
37         self.assertIsNone(self.sip_profile.generator)
38
39     def test_execute_traffic(self):
40         self.sip_profile.generator = None
41         mock_traffic_generator = mock.Mock()
42         self.sip_profile.execute_traffic(mock_traffic_generator)
43         self.assertIsNotNone(self.sip_profile.generator)
44
45     def test_is_ended_true(self):
46         self.sip_profile.generator = mock.Mock(return_value=True)
47         self.assertTrue(self.sip_profile.is_ended())
48
49     def test_is_ended_false(self):
50         self.sip_profile.generator = None
51         self.assertFalse(self.sip_profile.is_ended())