本文整理汇总了Python中testlib.function函数的典型用法代码示例。如果您正苦于以下问题:Python function函数的具体用法?Python function怎么用?Python function使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了function函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_set_description
def test_set_description(self):
for state in ['config', 'negate', 'default']:
value = 'this is a test'
name = 'test'
cmd = 'neighbor {} description'.format(name)
if state == 'config':
cmds = ['router bgp 65000', '{} {}'.format(cmd, value)]
func = function('set_description', name, value=value)
elif state == 'negate':
cmds = ['router bgp 65000', 'no {}'.format(cmd)]
func = function('set_description', name, disable=True)
elif state == 'default':
cmds = ['router bgp 65000', 'default {}'.format(cmd)]
func = function('set_description', name, value=value,
default=True)
self.eapi_positive_config_test(func, cmds)
# func = function('set_description', name, value=None, default=False,
# disable=False)
# self.eapi_exception_config_test(func, ValueError)
# If command_builder fails because value is None, uncomment
# above lines and remove below lines.
cmds = ['router bgp 65000', 'no neighbor test description']
func = function('set_description', 'test', None)
self.eapi_positive_config_test(func, cmds)
开发者ID:arista-eosplus,项目名称:pyeapi,代码行数:25,代码来源:test_api_bgp.py
示例2: test_set_route_map_out
def test_set_route_map_out(self):
for state in ['config', 'negate', 'default']:
route_map = 'TEST_RM'
name = 'test'
cmd = 'neighbor {} route-map'.format(name)
if state == 'config':
cmds = ['router bgp 65000', '{} {} out'.format(cmd, route_map)]
func = function('set_route_map_out', name, value=route_map)
elif state == 'negate':
cmds = ['router bgp 65000', 'no {} out'.format(cmd)]
func = function('set_route_map_out', name, disable=True)
elif state == 'default':
cmds = ['router bgp 65000', 'default {} out'.format(cmd)]
func = function('set_route_map_out', name, value=route_map,
default=True)
self.eapi_positive_config_test(func, cmds)
# func = function('set_route_map_out', name, value=None, default=False,
# disable=False)
# self.eapi_exception_config_test(func, ValueError)
# If command_builder fails because value is None, uncomment
# above lines and remove below lines.
cmds = ['router bgp 65000', 'no neighbor test route-map out']
func = function('set_route_map_out', 'test', None)
self.eapi_positive_config_test(func, cmds)
开发者ID:arista-eosplus,项目名称:pyeapi,代码行数:25,代码来源:test_api_bgp.py
示例3: test_set_primary_ip
def test_set_primary_ip(self):
# vrrp 10 ip 10.10.4.10
# Test set_primary_ip gives properly formatted commands
ip1 = '10.10.4.110'
ipcurr = '10.10.4.10'
cases = [
(ip1, None, None, 'vrrp %d ip %s' % (upd_vrid, ip1)),
(ip1, True, None, 'no vrrp %d ip %s' % (upd_vrid, ipcurr)),
(ip1, None, True, 'default vrrp %d ip %s' % (upd_vrid, ipcurr)),
(ip1, True, True, 'default vrrp %d ip %s' % (upd_vrid, ipcurr)),
]
for (primary_ip, disable, default, cmd) in cases:
func = function('set_primary_ip', upd_intf, upd_vrid,
value=primary_ip, disable=disable, default=default)
exp_cmds = [upd_cmd] + [cmd]
self.eapi_positive_config_test(func, exp_cmds)
# Test raising ValueError from invalid parameters
cases = ['abc', 500, '101.101']
for primary_ip in cases:
func = function('set_primary_ip', upd_intf, upd_vrid,
value=primary_ip)
self.eapi_exception_config_test(func, ValueError)
开发者ID:arista-eosplus,项目名称:pyeapi,代码行数:26,代码来源:test_api_vrrp.py
示例4: test_set_mac_addr_adv_interval
def test_set_mac_addr_adv_interval(self):
# vrrp 10 mac-address advertisement-interval 30
# Test set_timers_advertise gives properly formatted commands
maadvint = 'mac-address advertisement-interval'
cases = [
(50, None, None, 'vrrp %d %s 50' % (upd_vrid, maadvint)),
(None, None, True, 'default vrrp %d %s' % (upd_vrid, maadvint)),
(None, True, True, 'default vrrp %d %s' % (upd_vrid, maadvint)),
(None, True, None, 'no vrrp %d %s' % (upd_vrid, maadvint)),
]
for (mac_addr_adv_interval, disable, default, cmd) in cases:
func = function('set_mac_addr_adv_interval', upd_intf, upd_vrid,
value=mac_addr_adv_interval, disable=disable,
default=default)
exp_cmds = [upd_cmd] + [cmd]
self.eapi_positive_config_test(func, exp_cmds)
# Test raising ValueError by entering invalid parameters
cases = ['a', 10000]
for mac_addr_adv_interval in cases:
func = function('set_mac_addr_adv_interval', upd_intf, upd_vrid,
value=mac_addr_adv_interval)
self.eapi_exception_config_test(func, ValueError)
开发者ID:arista-eosplus,项目名称:pyeapi,代码行数:26,代码来源:test_api_vrrp.py
示例5: test_set_timers_advertise
def test_set_timers_advertise(self):
# vrrp 10 timers advertise 3
# Test set_timers_advertise gives properly formatted commands
cases = [
(50, None, None, 'vrrp %d timers advertise 50' % upd_vrid),
(None, None, True, 'default vrrp %d timers advertise' % upd_vrid),
(None, True, True, 'default vrrp %d timers advertise' % upd_vrid),
(None, True, None, 'no vrrp %d timers advertise' % upd_vrid),
]
for (timers_advertise, disable, default, cmd) in cases:
func = function('set_timers_advertise', upd_intf, upd_vrid,
value=timers_advertise, disable=disable,
default=default)
exp_cmds = [upd_cmd] + [cmd]
self.eapi_positive_config_test(func, exp_cmds)
# Test raising ValueError by entering invalid parameters
cases = [256, 0, 'a']
for timers_advertise in cases:
func = function('set_timers_advertise', upd_intf, upd_vrid,
value=timers_advertise)
self.eapi_exception_config_test(func, ValueError)
开发者ID:arista-eosplus,项目名称:pyeapi,代码行数:25,代码来源:test_api_vrrp.py
示例6: test_set_preempt
def test_set_preempt(self):
# vrrp 10 preempt
# Test set_description gives properly formatted commands
cases = [
(False, None, None, 'no vrrp %d preempt' % upd_vrid),
(True, None, None, 'vrrp %d preempt' % upd_vrid),
(None, None, True, 'default vrrp %d preempt' % upd_vrid),
(None, True, True, 'default vrrp %d preempt' % upd_vrid),
(None, True, None, 'no vrrp %d preempt' % upd_vrid),
]
for (preempt, disable, default, cmd) in cases:
func = function('set_preempt', upd_intf, upd_vrid,
value=preempt, disable=disable, default=default)
exp_cmds = [upd_cmd] + [cmd]
self.eapi_positive_config_test(func, exp_cmds)
# Test raising ValueError by entering invalid parameters
cases = ['a', 5]
for preempt in cases:
func = function('set_preempt', upd_intf, upd_vrid,
value=preempt)
self.eapi_exception_config_test(func, ValueError)
开发者ID:arista-eosplus,项目名称:pyeapi,代码行数:25,代码来源:test_api_vrrp.py
示例7: test_set_preempt_delay_min
def test_set_preempt_delay_min(self):
# vrrp 10 preempt delay minimum 0
# Test set_preempt_delay_min gives properly formatted commands
cases = [
(2500, None, None,
'vrrp %d preempt delay minimum 2500' % upd_vrid),
(None, None, True,
'default vrrp %d preempt delay minimum' % upd_vrid),
(None, True, True,
'default vrrp %d preempt delay minimum' % upd_vrid),
(None, True, None, 'no vrrp %d preempt delay minimum' % upd_vrid),
]
for (preempt_delay_min, disable, default, cmd) in cases:
func = function('set_preempt_delay_min', upd_intf, upd_vrid,
value=preempt_delay_min, disable=disable,
default=default)
exp_cmds = [upd_cmd] + [cmd]
self.eapi_positive_config_test(func, exp_cmds)
# Test raising ValueError by entering invalid parameters
cases = ['a', 3601]
for preempt_delay_min in cases:
func = function('set_preempt_delay_min', upd_intf, upd_vrid,
value=preempt_delay_min)
self.eapi_exception_config_test(func, ValueError)
开发者ID:arista-eosplus,项目名称:pyeapi,代码行数:28,代码来源:test_api_vrrp.py
示例8: test_set_delay_reload
def test_set_delay_reload(self):
# vrrp 10 delay reload 0
# Test set_delay_min gives properly formatted commands
cases = [
(1750, None, None, 'vrrp %d delay reload 1750' % upd_vrid),
(None, None, True, 'default vrrp %d delay reload' % upd_vrid),
(None, True, True, 'default vrrp %d delay reload' % upd_vrid),
(None, True, None, 'no vrrp %d delay reload' % upd_vrid),
]
for (delay_reload, disable, default, cmd) in cases:
func = function('set_delay_reload', upd_intf, upd_vrid,
value=delay_reload, disable=disable,
default=default)
exp_cmds = [upd_cmd] + [cmd]
self.eapi_positive_config_test(func, exp_cmds)
# Test raising ValueError by entering invalid parameters
cases = ['a', 3601]
for delay_reload in cases:
func = function('set_delay_reload', upd_intf, upd_vrid,
value=delay_reload)
self.eapi_exception_config_test(func, ValueError)
开发者ID:arista-eosplus,项目名称:pyeapi,代码行数:25,代码来源:test_api_vrrp.py
示例9: test_set_peer_group
def test_set_peer_group(self):
for state in ['config', 'negate', 'default']:
peer_group = 'test'
name = '172.16.10.1'
cmd = 'neighbor {} peer-group'.format(name)
if state == 'config':
cmds = ['router bgp 65000', '{} {}'.format(cmd, peer_group)]
func = function('set_peer_group', name, peer_group)
elif state == 'negate':
cmds = ['router bgp 65000', 'no {}'.format(cmd)]
func = function('set_peer_group', name, disable=True)
elif state == 'default':
cmds = ['router bgp 65000', 'default {}'.format(cmd)]
func = function('set_peer_group', name, peer_group,
default=True)
self.eapi_positive_config_test(func, cmds)
# func = function('set_peer_group', name, value=None, default=False,
# disable=False)
# self.eapi_exception_config_test(func, ValueError)
# If command_builder fails because value is None, uncomment
# above lines and remove below lines.
cmds = ['router bgp 65000', 'no neighbor 172.16.10.1 peer-group']
func = function('set_peer_group', '172.16.10.1', None)
self.eapi_positive_config_test(func, cmds)
开发者ID:arista-eosplus,项目名称:pyeapi,代码行数:25,代码来源:test_api_bgp.py
示例10: test_set_bfd_ip
def test_set_bfd_ip(self):
# no vrrp 10 bfd ip
bfd_addr = '10.10.4.101'
# Test bfd_ip gives properly formatted commands
cases = [
(bfd_addr, None, None, 'vrrp %d bfd ip %s' % (upd_vrid, bfd_addr)),
(None, True, None, 'no vrrp %d bfd ip' % upd_vrid),
(None, None, True, 'default vrrp %d bfd ip' % upd_vrid),
(None, True, True, 'default vrrp %d bfd ip' % upd_vrid),
]
for (bfd_ip, disable, default, cmd) in cases:
func = function('set_bfd_ip', upd_intf, upd_vrid,
value=bfd_ip, disable=disable, default=default)
exp_cmds = [upd_cmd] + [cmd]
self.eapi_positive_config_test(func, exp_cmds)
# Test raising ValueError from invalid parameters
cases = ['abc', 500, '101.101']
for bfd_ip in cases:
func = function('set_bfd_ip', upd_intf, upd_vrid,
value=bfd_ip)
self.eapi_exception_config_test(func, ValueError)
开发者ID:arista-eosplus,项目名称:pyeapi,代码行数:26,代码来源:test_api_vrrp.py
示例11: test_set_banner_default_disable
def test_set_banner_default_disable(self):
func = function('set_banner', banner_type='motd',
value=None, default=True)
cmds = 'default banner motd'
self.eapi_positive_config_test(func, cmds)
func = function('set_banner', banner_type='motd',
value=None, disable=True)
cmds = 'no banner motd'
self.eapi_positive_config_test(func, cmds)
开发者ID:arista-eosplus,项目名称:pyeapi,代码行数:9,代码来源:test_api_system.py
示例12: test_remove_network
def test_remove_network(self):
func = function('remove_network', '172.16.10.1', '24', 'test')
cmds = ['router bgp 65000', 'no network 172.16.10.1/24 route-map test']
self.eapi_positive_config_test(func, cmds)
func = function('remove_network', '', '24', 'test')
self.eapi_exception_config_test(func, ValueError)
func = function('remove_network', '172.16.10.1', '', 'test')
self.eapi_exception_config_test(func, ValueError)
开发者ID:arista-eosplus,项目名称:pyeapi,代码行数:10,代码来源:test_api_bgp.py
示例13: test_set_mtu_invalid_value_raises_value_error
def test_set_mtu_invalid_value_raises_value_error(self):
for intf in self.INTERFACES:
for value in [67, 65536, random_string()]:
func = function('set_mtu', intf, value)
self.eapi_exception_config_test(func, ValueError)
for value in [None]:
# If command_builder fails because value is None, put None
# in the first loop to check for value error, and remove
# this second loop
cmds = ['interface %s' % intf, 'no mtu']
func = function('set_mtu', intf, value)
self.eapi_positive_config_test(func, cmds)
开发者ID:brigoldberg,项目名称:pyeapi,代码行数:12,代码来源:test_api_ipinterfaces.py
示例14: test_set_shutdown
def test_set_shutdown(self):
for state in ['config', 'negate', 'default']:
if state == 'config':
cmds = ['router bgp 65000', 'shutdown']
func = function('set_shutdown', default=False, disable=False)
elif state == 'negate':
cmds = ['router bgp 65000', 'no shutdown']
func = function('set_shutdown', disable=True)
elif state == 'default':
cmds = ['router bgp 65000', 'default shutdown']
func = function('set_shutdown', default=True)
self.eapi_positive_config_test(func, cmds)
开发者ID:arista-eosplus,项目名称:pyeapi,代码行数:12,代码来源:test_api_bgp.py
示例15: test_set_iprouting
def test_set_iprouting(self):
for state in ['config', 'negate', 'default']:
if state == 'config':
cmds = 'ip routing'
func = function('set_iprouting', True)
elif state == 'negate':
cmds = 'no ip routing'
func = function('set_iprouting', disable=True)
elif state == 'default':
cmds = 'default ip routing'
func = function('set_iprouting', default=True)
self.eapi_positive_config_test(func, cmds)
开发者ID:arista-eosplus,项目名称:pyeapi,代码行数:12,代码来源:test_api_system.py
示例16: test_set_secondary_ips
def test_set_secondary_ips(self):
# vrrp 10 ip 10.10.4.21 secondary
# vrrp 10 ip 10.10.4.22 secondary
# vrrp 10 ip 10.10.4.23 secondary
curr1 = '10.10.4.21'
curr2 = '10.10.4.22'
curr3 = '10.10.4.23'
curr4 = '10.10.4.24'
new1 = '10.10.4.31'
new2 = '10.10.4.32'
new3 = '10.10.4.33'
new4 = curr4
# Test set_secondary_ips gives properly formatted commands
cases = [
([new1, new2, new3],
{'add': [new1, new2, new3],
'remove': [curr1, curr2, curr3, curr4]}),
([new1, new2, new4],
{'add': [new1, new2],
'remove': [curr1, curr2, curr3]}),
([],
{'add': [],
'remove': [curr1, curr2, curr3, curr4]}),
]
for (secondary_ips, cmd_dict) in cases:
cmds = []
for sec_ip in cmd_dict['add']:
cmds.append("vrrp %d ip %s secondary" % (upd_vrid, sec_ip))
for sec_ip in cmd_dict['remove']:
cmds.append("no vrrp %d ip %s secondary" % (upd_vrid, sec_ip))
func = function('set_secondary_ips', upd_intf, upd_vrid,
secondary_ips)
exp_cmds = [upd_cmd] + sorted(cmds)
self.eapi_positive_config_test(func, exp_cmds)
# Test raising ValueError by entering invalid parameters
cases = [
[new1, new2, 'abc'],
[new1, new2, '10.10.10'],
[new1, new2, True],
]
for secondary_ips in cases:
func = function('set_secondary_ips', upd_intf, upd_vrid,
secondary_ips)
self.eapi_exception_config_test(func, ValueError)
开发者ID:arista-eosplus,项目名称:pyeapi,代码行数:52,代码来源:test_api_vrrp.py
示例17: test_set_mlag_id
def test_set_mlag_id(self):
for state in ['config', 'negate', 'default']:
if state == 'config':
cmds = ['interface Ethernet1', 'mlag 1']
func = function('set_mlag_id', 'Ethernet1', '1')
elif state == 'negate':
cmds = ['interface Ethernet1', 'no mlag']
func = function('set_mlag_id', 'Ethernet1', disable=True)
elif state == 'default':
cmds = ['interface Ethernet1', 'default mlag']
func = function('set_mlag_id', 'Ethernet1', value='1',
default=True)
self.eapi_positive_config_test(func, cmds)
开发者ID:arista-eosplus,项目名称:pyeapi,代码行数:13,代码来源:test_api_mlag.py
示例18: test_set_domain_id
def test_set_domain_id(self):
for state in ['config', 'negate', 'default']:
cmds = ['mlag configuration']
if state == 'config':
cmds.append('domain-id test.dom-id string')
func = function('set_domain_id', 'test.dom-id string')
elif state == 'negate':
cmds.append('no domain-id')
func = function('set_domain_id', value='test', disable=True)
elif state == 'default':
cmds.append('default domain-id')
func = function('set_domain_id', value='test', default=True)
self.eapi_positive_config_test(func, cmds)
开发者ID:arista-eosplus,项目名称:pyeapi,代码行数:13,代码来源:test_api_mlag.py
示例19: test_maximum_paths_just_max_path
def test_maximum_paths_just_max_path(self):
for state in ['config', 'negate', 'default']:
max_paths = 20
if state == 'config':
cmds = ['router bgp 65000', 'maximum-paths 20']
func = function('set_maximum_paths', max_paths)
elif state == 'negate':
cmds = ['router bgp 65000', 'no maximum-paths']
func = function('set_maximum_paths')
elif state == 'default':
cmds = ['router bgp 65000', 'default maximum-paths']
func = function('set_maximum_paths', default=True)
self.eapi_positive_config_test(func, cmds)
开发者ID:dathelen,项目名称:pyeapi,代码行数:13,代码来源:test_api_bgp.py
示例20: test_set_router_id
def test_set_router_id(self):
for state in ['config', 'negate', 'default']:
rid = '1.1.1.1'
if state == 'config':
cmds = ['router bgp 65000', 'router-id 1.1.1.1']
func = function('set_router_id', rid)
elif state == 'negate':
cmds = ['router bgp 65000', 'no router-id']
func = function('set_router_id')
elif state == 'default':
cmds = ['router bgp 65000', 'default router-id']
func = function('set_router_id', rid, True)
self.eapi_positive_config_test(func, cmds)
开发者ID:dathelen,项目名称:pyeapi,代码行数:13,代码来源:test_api_bgp.py
注:本文中的testlib.function函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论