• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python asserts.mod_args_generator函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中asserts.mod_args_generator函数的典型用法代码示例。如果您正苦于以下问题:Python mod_args_generator函数的具体用法?Python mod_args_generator怎么用?Python mod_args_generator使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了mod_args_generator函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_is_bridgemem_port_type

    def test_is_bridgemem_port_type(self, mock_path_exists,
                                    mock_get_subints):
        # port is not a l2 port
        values = {'/sys/class/net/eth1/brport': False}
        mock_path_exists.side_effect = mod_args_generator(values)
        mock_get_subints.return_value = []
        assert_equals(self.iface.get_bridgemem_port_type(), 0)
        # port is not a l2 port but has subints that are l2 ports
        values = {'/sys/class/net/eth1/brport': False,
                  '/sys/class/net/eth1.100/brport': True}
        mock_get_subints.return_value = ['eth1.100']
        mock_path_exists.side_effect = mod_args_generator(values)
        assert_equals(self.iface.get_bridgemem_port_type(), 2)

        # port is an access
        mock_get_subints.return_value = []
        values = {'/sys/class/net/eth1/brport': True}
        mock_path_exists.side_effect = mod_args_generator(values)
        assert_equals(self.iface.get_bridgemem_port_type(), 1)
        # if port has native port that is in bridge and subints in bridge
        mock_get_subints.return_value = ['eth1.100']
        values = {'/sys/class/net/eth1/brport': True,
                  '/sys/class/net/eth1.100/brport': True}
        mock_path_exists.side_effect = mod_args_generator(values)
        assert_equals(self.iface.get_bridgemem_port_type(), 2)
开发者ID:benthomasson,项目名称:netshow-linux-lib,代码行数:25,代码来源:test_iface.py


示例2: test_read_link_state

 def test_read_link_state(self, mock_read_oneline):
     """ test get link state """
     # port is admin down
     values = {
         '/sys/class/net/eth1/carrier': None,
         '/sys/class/net/eth1/operstate': 'down'
     }
     mock_read_oneline.side_effect = mod_args_generator(values)
     assert_equals(self.iface.linkstate, 0)
     # port is down
     values = {
         '/sys/class/net/eth1/carrier': '0',
         '/sys/class/net/eth1/operstate': 'down'
     }
     mock_read_oneline.side_effect = mod_args_generator(values)
     assert_equals(self.iface.linkstate, 1)
     # clear link_state
     self.iface._linkstate = None
     # port is up
     values = {
         '/sys/class/net/eth1/carrier': '1',
         '/sys/class/net/eth1/operstate': 'up'
     }
     mock_read_oneline.side_effect = mod_args_generator(values)
     self.iface._linkstate = None
     assert_equals(self.iface.linkstate, 2)
     # port is dormant
     values = {
         '/sys/class/net/eth1/carrier': '1',
         '/sys/class/net/eth1/operstate': 'dormant'
     }
     mock_read_oneline.side_effect = mod_args_generator(values)
     self.iface._linkstate = None
     assert_equals(self.iface.linkstate, 3)
开发者ID:benthomasson,项目名称:netshow-linux-lib,代码行数:34,代码来源:test_iface.py


示例3: test_stp_state

 def test_stp_state(self, mock_read_from_sys, mock_exists, mock_subints):
     # test if iface is in stp bridge
     values = {
         '/sys/class/net/eth1/brport/bridge/bridge/stp_state': True
     }
     values2 = {
         'brport/bridge/bridge/stp_state': '2'
     }
     mock_exists.side_effect = mod_args_generator(values)
     mock_read_from_sys.side_effect = mod_args_generator(values2)
     _output = self.iface.stp_state()
     assert_equals(_output, '2')
     # test if subint is in stp bridge
     # assumption here is that only one type of stp bridge is running. either its
     # kernel or mstpd. even though in reality both I believe can coexist.
     values = {
         '/sys/class/net/eth1/brport/bridge/bridge/stp_state': False,
         '/sys/class/net/eth1.100/brport/bridge/bridge/stp_state': True
     }
     values2 = {
         'brport/bridge/bridge/stp_state': '2'
     }
     mock_exists.side_effect = mod_args_generator(values)
     mock_read_from_sys.side_effect = mod_args_generator(values2)
     mock_subints.return_value = ['eth1.100', 'eth1.101', 'eth1.110']
     _output = self.iface.stp_state()
     assert_equals(_output, '2')
开发者ID:benthomasson,项目名称:netshow-linux-lib,代码行数:27,代码来源:test_iface.py


示例4: test_bondstate

    def test_bondstate(self, mock_read_from_sys):
        values = {"carrier": "0", "operstate": "down", "bonding/mode": "active-backup 2"}
        mock_read_from_sys.side_effect = mod_args_generator(values)
        # mock_read_from_sys.return_value = 'active-backup 2'
        # if lacp is not set and linkstate is not up
        assert_equals(self.iface.bondstate, 0)

        # if lacp is not set and linkstate is up
        values = {"carrier": "1", "operstate": "up", "bonding/mode": "active-backup 2"}
        mock_read_from_sys.side_effect = mod_args_generator(values)
        assert_equals(self.iface.bondstate, 1)

        # if lacp is set and agg_id is same
        values = {"carrier": "1", "operstate": "up", "bonding/mode": "802.3ad 4"}
        mock_read_from_sys.side_effect = mod_args_generator(values)
        bondingfile = io.open("tests/test_netshowlib/proc_net_bonding_agg_id_match.txt")
        with mock.patch("io.open") as mock_open:
            mock_open.return_value = bondingfile
            assert_equals(self.iface.bondstate, 1)

        # if lacp is set and agg_id is different
        bondingfile = io.open("tests/test_netshowlib/proc_net_bonding_agg_id_no_match.txt")
        with mock.patch("io.open") as mock_open:
            mock_open.return_value = bondingfile
            assert_equals(self.iface.bondstate, 0)
开发者ID:benthomasson,项目名称:netshow-linux-lib,代码行数:25,代码来源:test_bond.py


示例5: test_vlan_filtering

 def test_vlan_filtering(self, mock_read_from_sys):
     values = {('bridge/vlan_filtering', 'br0'): '1'}
     mock_read_from_sys.side_effect = mod_args_generator(values)
     assert_equals(self.iface.vlan_filtering, 1)
     values = {('bridge/vlan_filtering', 'br0'): None}
     mock_read_from_sys.side_effect = mod_args_generator(values)
     assert_equals(self.iface.vlan_filtering, 0)
开发者ID:CumulusNetworks,项目名称:netshow-cumulus-lib,代码行数:7,代码来源:test_bridge.py


示例6: test_stp_details

    def test_stp_details(self, mock_read_from_sys, mock_exec,
                         mock_os_listdir):
        mock_exec.return_value = io.open(
            'tests/test_netshowlib/mstpctl_showall').read()
        values = {('bridge/vlan_filtering', 'br1'): None,
                  ('bridge/stp_state', 'br1', True): '2'}
        mock_read_from_sys.side_effect = mod_args_generator(values)
        values4 = {
            ('/sys/class/net/br1/brif',): ['swp3.1', 'swp4.1']
        }
        mock_os_listdir.side_effect = mod_args_generator(values4)
        _output = self.piface.stp_details()
        assert_equals(re.split(r'\s{3,}', _output.split('\n')[2]),
                      ['stp_mode:', 'RSTP / per vlan instance'])

        assert_equals(re.split(r'\s{3,}', _output.split('\n')[3]),
                      ['root_port:', 'root_switch'])
        assert_equals(re.split(r'\s{3,}', _output.split('\n')[4]),
                      ['ports_in_designated_role:  swp3-4'])
        assert_equals(re.split(r'\s{3,}', _output.split('\n')[5]),
                      ['ports_in_alternate_role:', 'none'])
        assert_equals(re.split(r'\s{3,}', _output.split('\n')[6]),
                      ['root_priority:', '32768'])
        assert_equals(re.split(r'\s{3,}', _output.split('\n')[7]),
                      ['bridge_priority:', '32768'])
        assert_equals(re.split(r'\s{3,}', _output.split('\n')[8]),
                      ['last_tcn:', 'swp4.1 (15 days, 20:34:24)'])
        assert_equals(re.split(r'\s{3,}', _output.split('\n')[9]),
                      ['802.1q_tag:', '1'])
开发者ID:CumulusNetworks,项目名称:netshow-cumulus-lib,代码行数:29,代码来源:test_print_bridge.py


示例7: test_stp_details

 def test_stp_details(self, mock_read_sys, mock_listdir,
                      mock_file_oneline, mock_is_root):
     mock_is_root.return_value = False
     mock_listdir.return_value = ['eth1', 'eth2']
     values1 = {
         'bridge/stp_state': '1',
         'bridge/root_id': '4000.fe54007e7eeb',
         'bridge/bridge_id': '8000.fe54007e7111'}
     values2 = {
         '/sys/class/net/eth1/brport/state': '3',
         '/sys/class/net/eth1/brport/bridge/bridge/root_port': '1',
         '/sys/class/net/eth1/brport/port_id': '1',
         '/sys/class/net/eth2/brport/state': '0',
         '/sys/class/net/eth2/brport/bridge/bridge/stp_state': '1',
         '/sys/class/net/eth2/brport/bridge/bridge/root_port': '1',
         '/sys/class/net/eth2/brport/port_id': '2',
     }
     mock_read_sys.side_effect = mod_args_generator(values1)
     mock_file_oneline.side_effect = mod_args_generator(values2)
     _output = self.piface.stp_details()
     _outputtable = _output.split('\n')
     assert_equals(re.split(r'\s{2,}', _outputtable[2]),
                   ['stp_mode:', '802.1d / per bridge instance'])
     assert_equals(_outputtable[3].split(),
                   ['root_port:', 'eth1'])
     assert_equals(_outputtable[4].split(),
                   ['root_priority:', '16384'])
     assert_equals(_outputtable[5].split(), ['bridge_priority:', '32768'])
     assert_equals(_outputtable[6].split(), ['802.1q_tag', 'untagged'])
开发者ID:benthomasson,项目名称:netshow-linux-lib,代码行数:29,代码来源:test_print_bridge.py


示例8: test_bondmem_details

    def test_bondmem_details(self, mock_read_from_sys, mock_file_oneline,
                             mock_lldp):
        values1 = {'carrier': '1', 'operstate': 'up',
                   'bonding/mode': '802.3ad 4',
                   'bonding/slaves': 'eth22 eth23',
                   'bonding/xmit_hash_policy': 'layer3+4 1',
                   'bonding/min_links': '2'}
        values2 = {'/sys/class/net/bond0/bonding/ad_sys_priority': '65535',
                   '/sys/class/net/bond0/bonding/lacp_rate': 'slow 0'}
        values = [{'adj_port': 'eth2',
                   'adj_hostname': 'switch1'},
                  {'adj_port': 'eth10',
                   'adj_hostname': 'switch2'}]
        mock_lldp.return_value = values
        mock_read_from_sys.side_effect = mod_args_generator(values1)
        mock_file_oneline.side_effect = mod_args_generator(values2)
        _output = self.piface.bondmem_details()
        _outputtable = _output.split('\n')
        assert_equals(len(_outputtable), 13)
        assert_equals(_outputtable[0].split(r'\s{3,}'), ['bond_details'])
        assert_equals(re.split(r'\s{3,}', _outputtable[2]), ['master_bond:', 'bond0'])
        assert_equals(re.split(r'\s{3,}', _outputtable[3]), ['state_in_bond:',
                                                             'port_not_in_bond'])
        assert_equals(re.split(r'\s{3,}', _outputtable[4]), ['link_failures:', '0'])
        assert_equals(re.split(r'\s{3,}', _outputtable[5]), ['bond_members:',
                                                             'eth22, eth23'])

        assert_equals(re.split(r'\s{3,}', _outputtable[6]), ['bond_mode:', 'lacp'])
        assert_equals(re.split(r'\s{3,}', _outputtable[7]), ['load_balancing:',
                                                             'layer3+4'])
        assert_equals(re.split(r'\s{3,}', _outputtable[8]), ['minimum_links:', '2'])
        assert_equals(re.split(r'\s{2,}', _outputtable[9]),
                      ['lacp_sys_priority:', '65535'])
        assert_equals(re.split(r'\s{3,}', _outputtable[10]), ['lacp_rate:', 'slow_lacp'])
开发者ID:benthomasson,项目名称:netshow-linux-lib,代码行数:34,代码来源:test_print_bond.py


示例9: test_stp_summary

 def test_stp_summary(self, mock_is_root, mock_read_from_sys,
                      mock_listdir, mock_oneline):
     # if stp is disabled
     mock_read_from_sys.return_value = '0'
     assert_equals(self.piface.stp_summary().split(), ['stp:', 'disabled'])
     # if stp is root
     values = {
         'bridge/stp_state': '1',
         'bridge/root_id': '4000.fe54007e7eeb',
         'bridge/bridge_id': '4000.fe54007e7eeb'}
     mock_read_from_sys.side_effect = mod_args_generator(values)
     mock_is_root.return_value = True
     assert_equals(self.piface.stp_summary().split(), ['stp:', 'rootswitch(16384)'])
     # if stp is not root
     values = {
         'bridge/stp_state': '1',
         'bridge/root_id': '4000.fe54007e7eeb',
         'bridge/bridge_id': '8000.fe54007e7111'}
     values2 = {
         '/sys/class/net/eth1/brport/state': '3',
         '/sys/class/net/eth1/brport/bridge/bridge/root_port': '1',
         '/sys/class/net/eth1/brport/port_id': '1',
         '/sys/class/net/eth2/brport/state': '0',
         '/sys/class/net/eth2/brport/bridge/bridge/stp_state': '1',
         '/sys/class/net/eth2/brport/bridge/bridge/root_port': '1',
         '/sys/class/net/eth2/brport/port_id': '2',
     }
     mock_oneline.side_effect = mod_args_generator(values2)
     mock_read_from_sys.side_effect = mod_args_generator(values)
     mock_is_root.return_value = False
     mock_listdir.return_value = ['eth1', 'eth2']
     assert_equals(self.piface.stp_summary().split(),
                   ['stp:', 'eth1(root)', '16384(root_priority)'])
开发者ID:benthomasson,项目名称:netshow-linux-lib,代码行数:33,代码来源:test_print_bridge.py


示例10: test_iface_discovery

def test_iface_discovery(mock_import, mock_provider_check):
    """ test iface discovery """
    # provider_check is none
    mock_provider_check.return_value = 'debian'
    mock_debian_iface = MagicMock()
    mock_debian_iface.iface.return_value = 'its a debian bridge'
    values = {'netshowlib.debian.iface': mock_debian_iface}
    mock_import.side_effect = mod_args_generator(values)
    assert_equals(nn.iface('eth1'), 'its a debian bridge')
    # if provider_check is not none
    mock_debian_iface = MagicMock()
    mock_debian_iface.iface.return_value = 'its a debian bridge'
    values['netshowlib.debian.iface'] = mock_debian_iface
    assert_equals(nn.iface('eth1', providername='debian'), 'its a debian bridge')
    # if cache is set provider_check is none
    mock_debian_iface.reset_mock()
    mock_debian_iface = MagicMock()
    mock_debian_iface.iface.return_value = 'its a debian bridge'
    mock_debian_cache = MagicMock()
    values = {'netshowlib.debian.iface': mock_debian_iface,
              'netshowlib.debian.cache': mock_debian_cache}
    mock_import.side_effect = mod_args_generator(values)
    all_cache = nn.feature_cache()
    assert_equals(nn.iface('eth1', cache=all_cache),
                  'its a debian bridge')
    # confirm syntax for iface_type accepts cache
    mock_debian_iface.iface.assert_called_with('eth1', cache=all_cache)
开发者ID:CumulusNetworks,项目名称:netshow-core,代码行数:27,代码来源:test_netshowlib.py


示例11: test_bridgemem_details_classic_driver

 def test_bridgemem_details_classic_driver(self,
                                           mock_stp_state,
                                           mock_is_bridgemem,
                                           mock_symlink,
                                           mock_exec,
                                           mock_listdir,
                                           mock_file,
                                           mock_read_oneline):
     values4 = {('/sys/class/net',): ['swp3', 'swp3.1', 'swp3.2'],
                ('/sys/class/net/br0/brif',): ['swp3'],
                ('/sys/class/net/br1/brif',): ['swp3.1'],
                ('/sys/class/net/br2/brif',): ['swp3.2']
                }
     mock_is_bridgemem.return_value = True
     mock_stp_state.return_value = '2'
     mock_listdir.side_effect = mod_args_generator(values4)
     mock_exec.return_value = io.open(
         'tests/test_netshowlib/mstpctl_showall').read()
     values = {('bridge/stp_state',): '2',
               ('brport/vlans',): None,
               ('/sys/class/net/swp3/brport/vlans',): None}
     mock_read_oneline.side_effect = mod_args_generator(values)
     values5 = {
         ('/sys/class/net/swp3/brport/bridge',): 'br0',
         ('/sys/class/net/swp3.1/brport/bridge',): 'br1',
         ('/sys/class/net/swp3.2/brport/bridge',): 'br2'
     }
     mock_symlink.side_effect = mod_args_generator(values5)
     self.piface.iface = cumulus_bridge.BridgeMember('swp3')
     _output = self.piface.bridgemem_details()
     _outputtable = _output.split('\n')
开发者ID:CumulusNetworks,项目名称:netshow-cumulus-lib,代码行数:31,代码来源:test_print_bridge.py


示例12: test_cli_output

    def test_cli_output(self, mock_read_from_sys, mock_exec,
                        mock_os_listdir):
        values10 = {('/sbin/mstpctl showall',):
                    io.open('tests/test_netshowlib/mstpctl_showall').read()}
        mock_exec.side_effect = mod_args_generator(values10)
        values = {('bridge/vlan_filtering', 'br1'): None,
                  ('bridge/stp_state', 'br1', True): '2',
                  ('carrier', 'br1', True): '1',
                  ('operstate', 'br1', True): 'up',
                  ('address', 'br1', True): '11:22:33:44:55:66',
                  ('speed', 'br1', True): '10000',
                  ('ifalias', 'br1', True): None,
                  ('operstate', 'br1', True): 'up',
                  ('mtu', 'br1', True): '1500'}
        mock_read_from_sys.side_effect = mod_args_generator(values)
        values4 = {
            ('/sys/class/net/br1/brif',): ['swp3.1', 'swp4.1']
        }
        mock_os_listdir.side_effect = mod_args_generator(values4)
        _output = self.piface.cli_output()
        _outputtable = _output.split('\n')
        # checks to make sure stp details is there
        assert_equals(re.split(r'\s{3,}', _outputtable[10]),
                      ['root_priority:', '32768'])

        assert_equals(_outputtable[17], 'ports in Forwarding state')
        assert_equals(_outputtable[19], 'swp3-4')
开发者ID:CumulusNetworks,项目名称:netshow-cumulus-lib,代码行数:27,代码来源:test_print_bridge.py


示例13: test_state_access_port

 def test_state_access_port(self, mock_symlink, mock_os_path,
                            mock_oneline):
     mock_subint = MagicMock()
     self.iface.get_sub_interfaces = mock_subint
     # bridgemember is access port
     mock_subint = []
     mock_symlink.return_value = 'br10'
     values = {
         '/sys/class/net/eth1/brport': True,
         '/sys/class/net/eth1/brport/bridge/bridge/stp_state': '1'
     }
     values2 = {
         '/sys/class/net/eth1/brport/state': '3',
         '/sys/class/net/eth1/brport/bridge/bridge/root_port': 'aaa',
         '/sys/class/net/eth1/brport/bridge/bridge/stp_state': '1',
         '/sys/class/net/eth1/brport/port_id': 'aaa'
     }
     mock_oneline.side_effect = mod_args_generator(values2)
     mock_os_path.side_effect = mod_args_generator(values)
     briface = linux_bridge.Bridge('br10')
     linux_bridge.BRIDGE_CACHE['br10'] = briface
     assert_equals(self.stp.state, {
         'disabled': [],
         'blocking': [],
         'forwarding': [briface],
         'root': [briface],
         'intransition': [],
         'stp_disabled': []
     })
开发者ID:benthomasson,项目名称:netshow-linux-lib,代码行数:29,代码来源:test_bridge.py


示例14: test_bond_details

 def test_bond_details(self, mock_read_from_sys, mock_file_oneline):
     # with lacp
     values1 = {'bonding/mode': '802.3ad 4',
                'bonding/xmit_hash_policy': 'layer3+4 2',
                'bonding/min_links': '2'}
     values2 = {
         '/sys/class/net/bond0/bonding/ad_sys_priority': '65535',
         '/sys/class/net/bond0/bonding/lacp_rate': 'fast 1'
     }
     mock_read_from_sys.side_effect = mod_args_generator(values1)
     mock_file_oneline.side_effect = mod_args_generator(values2)
     _output = self.piface.bond_details()
     _outputtable = _output.split('\n')
     assert_equals(_outputtable[0], 'bond_details')
     assert_equals(_outputtable[2].split(), ['bond_mode:', 'lacp'])
     assert_equals(_outputtable[3].split(), ['load_balancing:', 'layer2+3'])
     assert_equals(_outputtable[4].split(), ['minimum_links:', '2'])
     assert_equals(_outputtable[5].split(), ['lacp_sys_priority:', '65535'])
     assert_equals(_outputtable[6].split(), ['lacp_rate:', 'fast_lacp'])
     assert_equals(len(_output.split('\n')), 9)
     # without lacp
     values1 = {'bonding/mode': 'something_else 2',
                'bonding/xmit_hash_policy': 'layer3+4 2',
                'bonding/min_links': '2'}
     mock_read_from_sys.side_effect = mod_args_generator(values1)
     _output = self.piface.bond_details()
     assert_equals(len(_output.split('\n')), 7)
开发者ID:benthomasson,项目名称:netshow-linux-lib,代码行数:27,代码来源:test_print_bond.py


示例15: test_is_vlan_aware_bridge

    def test_is_vlan_aware_bridge(self, mock_read_from_sys):
        values = {('bridge/vlan_filtering', 'br1'): '1'}
        mock_read_from_sys.side_effect = mod_args_generator(values)
        assert_equals(self.piface.is_vlan_aware_bridge(), 'vlan_aware_bridge')

        values = {('bridge/vlan_filtering', 'br1'): None}
        mock_read_from_sys.side_effect = mod_args_generator(values)
        assert_equals(self.piface.is_vlan_aware_bridge(), '')
开发者ID:CumulusNetworks,项目名称:netshow-cumulus-lib,代码行数:8,代码来源:test_print_bridge.py


示例16: test_summary

 def test_summary(self, mock_read_from_sys, mock_file_oneline):
     values1 = {'carrier': '1', 'operstate': 'up',
                'operstate': 'up',
                'bonding/mode': 'something 2'}
     values2 = {}
     mock_read_from_sys.side_effect = mod_args_generator(values1)
     mock_file_oneline.side_effect = mod_args_generator(values2)
     assert_equals(self.piface.summary, ['master: bond0(UP)'])
开发者ID:benthomasson,项目名称:netshow-linux-lib,代码行数:8,代码来源:test_print_bond.py


示例17: test_get_stp_root_state

 def test_get_stp_root_state(self, mock_read_oneline):
     values = {'/sys/class/net/br0/bridge/root_id': '8000.3332222111',
               '/sys/class/net/br0/bridge/bridge_id': '8000.3332222111'}
     mock_read_oneline.side_effect = mod_args_generator(values)
     assert_equals(self.stp.is_root(), True)
     values = {'/sys/class/net/br0/bridge/root_id': '8000.3332222222',
               '/sys/class/net/br0/bridge/bridge_id': '8000.3332222111'}
     mock_read_oneline.side_effect = mod_args_generator(values)
     assert_equals(self.stp.is_root(), False)
开发者ID:benthomasson,项目名称:netshow-linux-lib,代码行数:9,代码来源:test_bridge.py


示例18: test_designated_ports

 def test_designated_ports(self, mock_read_from_sys, mock_exec,
                           mock_os_listdir):
     mock_exec.return_value = io.open(
         'tests/test_netshowlib/mstpctl_showall').read()
     values = {('bridge/vlan_filtering', 'br1', True): None,
               ('bridge/stp_state', 'br1', True): '2'}
     mock_read_from_sys.side_effect = mod_args_generator(values)
     values4 = {
         ('/sys/class/net/br1/brif',): ['swp3.1', 'swp4.1']
     }
     mock_os_listdir.side_effect = mod_args_generator(values4)
     assert_equals(self.piface.designated_ports(), ['swp3-4'])
开发者ID:CumulusNetworks,项目名称:netshow-cumulus-lib,代码行数:12,代码来源:test_print_bridge.py


示例19: test_state_trunk_port

    def test_state_trunk_port(self, mock_symlink, mock_os_path,
                              mock_oneline):
        mock_subint = MagicMock()
        mock_subint.return_value = ['eth1.11', 'eth1.20', 'eth1.30']
        self.iface.get_sub_interfaces = mock_subint
        # bridgemember is trunk port
        values = {
            '/sys/class/net/eth1/brport/bridge/bridge/stp_state': True,
            '/sys/class/net/eth1.11/brport/bridge/bridge/stp_state': True,
            '/sys/class/net/eth1.20/brport/bridge/bridge/stp_state': True,
            '/sys/class/net/eth1.30/brport/bridge/bridge/stp_state': True,
            '/sys/class/net/eth1/brport': True,
            '/sys/class/net/eth1.11/brport': True,
            '/sys/class/net/eth1.20/brport': False,
            '/sys/class/net/eth1.30/brport': True,
        }
        values2 = {
            '/sys/class/net/eth1/brport/state': '3',
            '/sys/class/net/eth1/brport/bridge/bridge/root_port': 'aaa',
            '/sys/class/net/eth1/brport/bridge/bridge/stp_state': '1',
            '/sys/class/net/eth1/brport/port_id': 'aaa',
            '/sys/class/net/eth1.11/brport/state': '0',
            '/sys/class/net/eth1.11/brport/bridge/bridge/stp_state': '1',
            '/sys/class/net/eth1.11/brport/bridge/bridge/root_port': 'aaa',
            '/sys/class/net/eth1.11/brport/port_id': 'aaa',
            '/sys/class/net/eth1.30/brport/state': '0',
            '/sys/class/net/eth1.30/brport/bridge/bridge/stp_state': '0'

        }
        values3 = {
            '/sys/class/net/eth1/brport/bridge': 'br10',
            '/sys/class/net/eth1.11/brport/bridge': 'br11',
            '/sys/class/net/eth1.20/brport/bridge': None,
            '/sys/class/net/eth1.30/brport/bridge': 'br30'
        }
        mock_symlink.side_effect = mod_args_generator(values3)
        mock_oneline.side_effect = mod_args_generator(values2)
        mock_os_path.side_effect = mod_args_generator(values)
        br10 = linux_bridge.Bridge('br10')
        br11 = linux_bridge.Bridge('br11')
        br30 = linux_bridge.Bridge('br30')
        linux_bridge.BRIDGE_CACHE['br10'] = br10
        linux_bridge.BRIDGE_CACHE['br11'] = br11
        linux_bridge.BRIDGE_CACHE['br30'] = br30
        assert_equals(self.stp.state, {
            'disabled': [br11],
            'blocking': [],
            'forwarding': [br10],
            'root': [br10],
            'stp_disabled': [br30],
            'intransition': []
        })
开发者ID:benthomasson,项目名称:netshow-linux-lib,代码行数:52,代码来源:test_bridge.py


示例20: test_alternate_ports

 def test_alternate_ports(self, mock_read_from_sys, mock_exec,
                          mock_os_listdir):
     self.piface.iface = cumulus_bridge.Bridge('br0')
     mock_exec.return_value = io.open(
         'tests/test_netshowlib/mstpctl_showall').read()
     values = {('bridge/vlan_filtering', 'br0'): None,
               ('bridge/stp_state', 'br0', True): '2'}
     mock_read_from_sys.side_effect = mod_args_generator(values)
     values4 = {
         ('/sys/class/net/br0/brif',): ['swp3', 'swp4']
     }
     mock_os_listdir.side_effect = mod_args_generator(values4)
     assert_equals(self.piface.alternate_ports(), ['swp4'])
开发者ID:CumulusNetworks,项目名称:netshow-cumulus-lib,代码行数:13,代码来源:test_print_bridge.py



注:本文中的asserts.mod_args_generator函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python assetapp.t函数代码示例发布时间:2022-05-24
下一篇:
Python asserts.assert_equals函数代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap