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

Python asserts.assert_equals函数代码示例

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

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



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


示例16: test_getting_list_of_ports

def test_getting_list_of_ports(mock_module, mock_read_dir):
    """ cl_int_policy - get list of current configured ports """
    mock_read_dir.return_value = ['swp1', 'swp2']
    mock_module.params = {'location': '/etc/network/interfaces.d'}
    cl_int_policy.read_current_int_dir(mock_module)
    mock_read_dir.assert_called_with('/etc/network/interfaces.d')
    assert_equals(mock_module.custom_currentportlist, ['swp1', 'swp2'])
开发者ID:CumulusNetworks,项目名称:cumulus-linux-ansible-modules,代码行数:7,代码来源:test_cl_interface_policy.py


示例17: test_modify_switch_config

def test_modify_switch_config(mock_module, mock_os):
    """
    cl_interface - test with inet method
    """
    instance = mock_module.return_value
    mock_os.path.exists.return_value = False
    testwrite = open('/tmp/test.me', 'w')
    iface = loop_iface()
    with mock.patch('__builtin__.open') as mock_open:
        mock_open.return_value = testwrite
        modify_switch_config(instance, iface)
        mock_open.assert_called_with('/etc/network/ansible/lo', 'w')

    mock_os.path.exists.assert_called_with('/etc/network/ansible/')
    fstr = 'auto lo\n'
    fstr += 'iface lo inet loopback\n'
    fstr += '    address 10:3:3::3/128\n'
    fstr += '    address 10.3.3.3/32\n'
    output = open('/tmp/test.me').readlines()
    assert_equals(''.join(output), fstr)

    # test when addr_method is not present
    iface = empty_iface()
    testwrite = open('/tmp/test.me', 'w')
    with mock.patch('__builtin__.open') as mock_open:
        mock_open.return_value = testwrite
        modify_switch_config(instance, iface)
        mock_open.assert_called_with('/etc/network/ansible/swp1', 'w')
    fstr = 'auto swp1\n'
    fstr += 'iface swp1\n'
    output = open('/tmp/test.me').readlines()
    assert_equals(''.join(output), fstr)
开发者ID:rnilekani,项目名称:cumulus-linux-ansible-modules,代码行数:32,代码来源:test_cl_interface.py


示例18: test_convert_allowed_list_to_port_range

def test_convert_allowed_list_to_port_range(mock_module):
    """ cl_int_policy - test getting allow list """
    mock_module.custom_allowedportlist = []
    mock_module.params = {'allowed': ['swp1', 'swp10-11', 'bond0-2']}
    cl_int_policy.convert_allowed_list_to_port_range(mock_module)
    assert_equals(mock_module.custom_allowedportlist,
                  ['swp1', 'swp10', 'swp11', 'bond0', 'bond1', 'bond2'])
开发者ID:CumulusNetworks,项目名称:cumulus-linux-ansible-modules,代码行数:7,代码来源:test_cl_interface_policy.py


示例19: test_port_category

 def test_port_category(self, mock_is_l3):
     # if l3
     mock_is_l3.return_value = True
     assert_equals(self.piface.port_category, 'bridge/l3')
     # if l3 is not true
     mock_is_l3.return_value = False
     assert_equals(self.piface.port_category, 'bridge/l2')
开发者ID:benthomasson,项目名称:netshow-linux-lib,代码行数:7,代码来源:test_print_bridge.py


示例20: test_unconfigure_interfaces

def test_unconfigure_interfaces(mock_module, mock_unlink):
    mock_module.custom_currentportlist = ['swp1', 'swp2', 'bond0', 'bond1']
    mock_module.custom_allowedportlist = ['swp1', 'swp2']
    cl_int_policy.unconfigure_interfaces(mock_module)
    assert_equals(mock_unlink.call_count, 2)
    assert_equals(mock_module.msg,
                  'remove config for interfaces bond0, bond1')
开发者ID:CumulusNetworks,项目名称:cumulus-linux-ansible-modules,代码行数:7,代码来源:test_cl_interface_policy.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python asserts.mod_args_generator函数代码示例发布时间:2022-05-24
下一篇:
Python asserts.assert_equal函数代码示例发布时间: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