当前位置: 首页>>代码示例>>Python>>正文


Python asserts.assert_equals函数代码示例

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


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

示例1: test_get_bond_mode

 def test_get_bond_mode(self, mock_file_oneline):
     mock_file_oneline.return_value = "802.3ad 4"
     assert_equals(self.iface.mode, "4")
     mock_file_oneline.assert_called_with("/sys/class/net/bond0/bonding/mode")
     # test failing to find something
     mock_file_oneline.return_value = None
     assert_equals(self.iface.mode, None)
开发者ID:benthomasson,项目名称:netshow-linux-lib,代码行数:7,代码来源:test_bond.py

示例2: test_parse_ip_cache

 def test_parse_ip_cache(self):
     """ testing parsing ip cache info """
     _output = io.open('tests/test_netshowlib/ip_addr_show.txt').read()
     output = io.StringIO(_output)
     result = ip_address_mod.parse_ip_cache(output)
     assert_equals(
         result,
         {
             'vnet-v0': {'ipv6': [], 'ipv4': ['192.168.1.1/23']},
             'lo': {
                 'ipv4': ['127.0.0.1/8'],
                 'ipv6': ['::1/128']
             },
             'net2compute': {
                 'ipv4': ['192.168.50.1/24'],
                 'ipv6': []
             },
             'virbr0': {
                 'ipv4': ['192.168.122.1/24'],
                 'ipv6': []
             },
             'vnet0': {
                 'ipv4': [],
                 'ipv6': []
             },
             'eth0': {
                 'ipv4': ['192.168.0.33/24'],
                 'ipv6': []
             }
         })
开发者ID:benthomasson,项目名称:netshow-linux-lib,代码行数:30,代码来源:test_ip_address.py

示例3: test_ifacelist_l2_subints

 def test_ifacelist_l2_subints(self, mock_bridgemem_test,
                               mock_cache, mock_portname_list, mock_exists):
     mock_exists.return_value = True
     # make sure L2 subints don't get into the list
     mock_bridgemem_test.return_value = True
     mock_portname_list.return_value = ['eth1.1', 'eth2.1']
     assert_equals(self.showint.ifacelist.get('all'), OrderedDict())
开发者ID:benthomasson,项目名称:netshow-linux-lib,代码行数:7,代码来源:test_show_interfaces.py

示例4: 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

示例5: test_img_install

def test_img_install(mock_module, mock_run_cl_cmd,
                     mock_get_slot_info, mock_switch_slot):
    """
    Test install image
    """
    instance = mock_module.return_value
    instance.params.get.side_effect = mod_args_generator(arg_values)
    instance.sw_version = '2.0.3'
    install_img(instance)
    cmd = '/usr/cumulus/bin/cl-img-install -f %s' % \
        (arg_values.get('src'))
    mock_run_cl_cmd.assert_called_with(instance, cmd)
    instance.exit_json.assert_called_with(
        msg='Cumulus Linux Version 2.0.3 ' +
        'successfully installed in alternate slot',
        changed=True)
    # test using when switching slots
    values = arg_values.copy()
    values['switch_slot'] = True
    instance.params.get.side_effect = mod_args_generator(values)
    mock_get_slot_info.return_value = {'1': {'version': '2.0.2',
                                             'active': True,
                                             'primary': True},
                                       '2': {'version': '2.0.3'}}
    instance.sw_version = '2.0.3'
    install_img(instance)
    assert_equals(mock_switch_slot.call_count, 1)
开发者ID:rnilekani,项目名称:cumulus-linux-ansible-modules,代码行数:27,代码来源:test_cl_img_install.py

示例6: test_appending_ansible_to_etc_network_interface

def test_appending_ansible_to_etc_network_interface(mock_module):
    instance = mock_module.return_value
    origfile = open('tests/interface_with_ansible.txt', 'r')
    newfile = open('tests/output.txt', 'w')
    mock_open = mock.Mock(side_effect=[origfile, newfile])
    iface = {'name': 'swp2'}
    with mock.patch('__builtin__.open', mock_open):
        remove_config_from_etc_net_interfaces(instance, iface)
    expected = [call('/etc/network/interfaces', 'r'),
                call('/etc/network/interfaces', 'w')]
    assert_equals(mock_open.call_args_list, expected)
    f = open('tests/output.txt')
    output = f.readlines()
    assert_equals(output,
                  ['auto lo\n', 'iface lo inet loopback\n',
                   '  address 1.1.1.1/32\n',
                   '\n',
                   'auto eth0\n',
                   'iface eth0 inet dhcp\n',
                   '\n',
                   'auto swp1\n',
                   'iface swp1\n',
                   '   speed 1000\n',
                   '\n',
                   '## Ansible controlled interfaces found here\n',
                   'source /etc/network/ansible/*\n'])
开发者ID:rnilekani,项目名称:cumulus-linux-ansible-modules,代码行数:26,代码来源:test_cl_interface.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_check_mod_args

def test_check_mod_args(
    mock_module, mock_check_dsl_dependencies, mock_has_interface_config, mock_add_global_ospf, mock_config_ospf_int
):
    """
    cl_quagga_ospf - check mod args
    """
    instance = mock_module.return_value
    instance.params.get.return_value = MagicMock()
    main()
    mock_module.assert_called_with(
        argument_spec={
            "router_id": {"type": "str"},
            "area": {"type": "str"},
            "reference_bandwidth": {"default": "40000", "type": "str"},
            "saveconfig": {
                "type": "bool",
                "default": False,
                "choices": ["yes", "on", "1", "true", 1, "no", "off", "0", "false", 0],
            },
            "state": {"type": "str", "choices": ["present", "absent"]},
            "cost": {"type": "str"},
            "interface": {"type": "str"},
            "passive": {"type": "bool", "choices": ["yes", "on", "1", "true", 1, "no", "off", "0", "false", 0]},
            "point2point": {"type": "bool", "choices": ["yes", "on", "1", "true", 1, "no", "off", "0", "false", 0]},
        },
        mutually_exclusive=[["reference_bandwidth", "interface"], ["router_id", "interface"]],
    )
    assert_equals(
        mock_check_dsl_dependencies.call_args_list[0],
        mock.call(instance, ["cost", "state", "area", "point2point", "passive"], "interface", "swp1"),
    )
    instance.exit_json.assert_called_with(msg="no change", changed=False)
开发者ID:CumulusNetworks,项目名称:cldemo-archive,代码行数:32,代码来源:test_cl_quagga_ospf.py

示例9: test_connector_type

 def test_connector_type(self):
     self.piface.iface._asic = {'asicname': 'ge1', 'initial_speed': '1000'}
     assert_equals(self.piface.connector_type, 'rj45')
     self.piface.iface._connector_type = None
     self.piface.iface._name = 'swp2s0'
     self.piface.iface._asic = {'asicname': 'xe1', 'initial_speed': '1000'}
     assert_equals(self.piface.connector_type, '4x10g')
开发者ID:CumulusNetworks,项目名称:netshow-cumulus-lib,代码行数:7,代码来源:test_print_iface.py

示例10: test_get_list_of_bridge_members

 def test_get_list_of_bridge_members(self, mock_listdirs):
     bridgemems = ['eth8', 'eth9']
     mock_listdirs.return_value = bridgemems
     assert_equals(sorted(list(self.iface.members.keys())), sorted(bridgemems))
     assert_equals(isinstance(self.iface.members.get('eth8'),
                              linux_bridge.BridgeMember), True)
     mock_listdirs.assert_called_with('/sys/class/net/br0/brif')
开发者ID:benthomasson,项目名称:netshow-linux-lib,代码行数:7,代码来源:test_bridge.py

示例11: test_get_todays_date

def test_get_todays_date():
    """
    cl_license. test that getting current date returns a date,
    not a string or None
    """
    result = get_todays_date()
    assert_equals(isinstance(result, datetime), True)
开发者ID:CumulusNetworks,项目名称:cldemo-archive,代码行数:7,代码来源:test_cl_license.py

示例12: 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

示例13: 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

示例14: test_get_bond_xmit_hash_policy

 def test_get_bond_xmit_hash_policy(self, mock_file_oneline):
     mock_file_oneline.return_value = "layer3+4 1"
     assert_equals(self.iface.hash_policy, "1")
     mock_file_oneline.assert_called_with("/sys/class/net/bond0/bonding/xmit_hash_policy")
     # test failing to find something
     mock_file_oneline.return_value = None
     assert_equals(self.iface.hash_policy, None)
开发者ID:benthomasson,项目名称:netshow-linux-lib,代码行数:7,代码来源:test_bond.py

示例15: test_add_ipv4

def test_add_ipv4(mock_module):
    addr = ['10.1.1.1/24']
    # addr is empty
    instance = mock_module.return_value
    instance.params.get.return_value = None
    iface = {'config': {}}
    add_ipv4(instance, iface)
    assert_equals('address' in iface['config'], False)
    # addr is not empty
    instance.params.get.return_value = addr
    iface = {'ifacetype': 'lo', 'config': {}}
    add_ipv4(instance, iface)
    assert_equals(iface['config']['address'], addr[0])
    # addr is none, array - remove it
    instance.params.get.return_value = ['none']
    iface = {'config': {}}
    add_ipv4(instance, iface)
    assert_equals(iface['config']['address'], None)
    # addr is none , str - remote it
    instance.params.get.return_value = u'none'
    iface = {'config': {}}
    add_ipv4(instance, iface)
    assert_equals(iface['config']['address'], None)
    # addr is not empty. multiple entries
    instance.params.get.return_value = ['1', '2']
    iface = {'config': {}}
    add_ipv4(instance, iface)
    assert_equals(iface['config']['address'], ['1', '2'])
开发者ID:rnilekani,项目名称:cumulus-linux-ansible-modules,代码行数:28,代码来源:test_cl_interface.py


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