Debian Codegraph @

neutron_lib/tests/unit/agent/common/test_utils.py

raw
1 # Copyright 2022
2 # All Rights Reserved.
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License"); you may
5 # not use this file except in compliance with the License. You may obtain
6 # a copy of the License at
7 #
8 # http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 # License for the specific language governing permissions and limitations
14 # under the License.
15
16 from neutron_lib.agent.common import constants
17 from neutron_lib.agent.common import utils
18 from neutron_lib.tests import _base
19
20
21 class TestCreateRegNumbers(_base.BaseTestCase):
22 def test_no_registers_defined(self):
23 flow = {'foo': 'bar'}
24 utils.create_reg_numbers(flow)
25 self.assertEqual({'foo': 'bar'}, flow)
26
27 def test_all_registers_defined(self):
28 flow = {'foo': 'bar',
29 constants.PORT_REG_NAME: 1,
30 constants.NET_REG_NAME: 2,
31 constants.REMOTE_GROUP_REG_NAME: 3,
32 constants.INGRESS_BW_LIMIT_REG_NAME: 4,
33 constants.MIN_BW_REG_NAME: 5}
34 expected_flow = {'foo': 'bar',
35 f'reg{constants.REG_PORT:d}': 1,
36 f'reg{constants.REG_NET:d}': 2,
37 f'reg{constants.REG_REMOTE_GROUP:d}': 3,
38 f'reg{constants.REG_INGRESS_BW_LIMIT:d}': 4,
39 f'reg{constants.REG_MIN_BW:d}': 5}
40 utils.create_reg_numbers(flow)
41 self.assertEqual(expected_flow, flow)