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

Python testlib.random_string函数代码示例

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

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



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

示例1: test_get_check_banners

 def test_get_check_banners(self):
     for dut in self.duts:
         motd_banner_value = random_string() + "\n"
         login_banner_value = random_string() + "\n"
         dut.config([dict(cmd="banner motd", input=motd_banner_value)])
         dut.config([dict(cmd="banner login", input=login_banner_value)])
         resp = dut.api('system').get()
         self.assertEqual(resp['banner_login'], login_banner_value.rstrip())
         self.assertEqual(resp['banner_motd'], motd_banner_value.rstrip())
开发者ID:arista-eosplus,项目名称:pyeapi,代码行数:9,代码来源:test_api_system.py


示例2: test_config_with_multiple_multilines

    def test_config_with_multiple_multilines(self):
        commands = [random_string(),
                    ('banner login MULTILINE:This is a new banner\n'
                    'with different lines!!!'),
                    random_string()]

        self.node.run_commands = Mock(return_value=[{}, {}, {}, {}])
        result = self.node.config(commands)
        self.assertEqual(result, [{}, {}, {}])
开发者ID:brigoldberg,项目名称:pyeapi,代码行数:9,代码来源:test_client.py


示例3: test_set_banner_motd

 def test_set_banner_motd(self):
     for dut in self.duts:
         banner_value = random_string()
         dut.config([dict(cmd="banner motd",
                          input=banner_value)])
         self.assertIn(banner_value, dut.running_config)
         banner_api_value = random_string()
         resp = dut.api('system').set_banner("motd", banner_api_value)
         self.assertTrue(resp, 'dut=%s' % dut)
         self.assertIn(banner_api_value, dut.running_config)
开发者ID:arista-eosplus,项目名称:pyeapi,代码行数:10,代码来源:test_api_system.py


示例4: test_set_banner_login

 def test_set_banner_login(self):
     for dut in self.duts:
         banner_value = random_string()
         dut.config([dict(cmd="banner login",
                          input=banner_value)])
         self.assertIn(banner_value, dut.running_config)
         banner_api_value = random_string()
         resp = dut.api('system').set_banner("login", banner_api_value)
         self.assertTrue(resp, 'dut=%s' % dut)
         self.assertIn(banner_api_value, dut.running_config)
         config_login_banner = dut.api('system').get()['banner_login']
         self.assertTrue(config_login_banner, banner_api_value.strip())
开发者ID:arista-eosplus,项目名称:pyeapi,代码行数:12,代码来源:test_api_system.py


示例5: test_set_trunk_groups

 def test_set_trunk_groups(self):
     for dut in self.duts:
         vid = str(random_int(2, 4094))
         tg1 = random_string(maxchar=10)
         tg2 = random_string(maxchar=10)
         tg3 = random_string(maxchar=10)
         dut.config(['no vlan %s' % vid, 'vlan %s' % vid,
                     'trunk group %s' % tg1, 'trunk group %s' % tg2])
         result = dut.api('vlans').set_trunk_groups(vid, [tg1, tg3])
         self.assertTrue(result, 'dut=%s' % dut)
         config = dut.run_commands('show vlan %s trunk group' % vid)
         config = sorted(config[0]['trunkGroups'][vid]['names'])
         self.assertEqual(sorted([tg1, tg3]), config)
开发者ID:arista-eosplus,项目名称:pyeapi,代码行数:13,代码来源:test_api_vlans.py


示例6: test_load_config_for_connection_with_env

 def test_load_config_for_connection_with_env(self):
     os.environ['EAPI_CONF'] = get_fixture('eapi.conf')
     pyeapi.client.load_config(random_string())
     cfg = pyeapi.client.config.get_connection('test1')
     self.assertEqual(cfg['host'], '192.168.1.16')
     self.assertEqual(cfg['username'], 'eapi')
     self.assertEqual(cfg['password'], 'password')
开发者ID:GaryCarneiro,项目名称:pyeapi,代码行数:7,代码来源:test_client.py


示例7: test_set_hostname_with_value

 def test_set_hostname_with_value(self):
     for dut in self.duts:
         dut.config('default hostname')
         value = random_string()
         response = dut.api('system').set_hostname(value)
         self.assertTrue(response, 'dut=%s' % dut)
         value = 'hostname %s' % value
         self.assertIn(value, dut.running_config)
开发者ID:arista-eosplus,项目名称:pyeapi,代码行数:8,代码来源:test_api_system.py


示例8: test_config_multiple_commands

 def test_config_multiple_commands(self):
     for dut in self.duts:
         commands = list()
         for i in range(1, random_int(10, 200)):
             commands.append('hostname %s' % random_string(5, 20))
         result = dut.config(commands[:])
         self.assertIsInstance(result, list, 'dut=%s' % dut)
         self.assertEqual(len(result), len(commands), 'dut=%s' % dut)
开发者ID:CullyB,项目名称:pyeapi,代码行数:8,代码来源:test_client.py


示例9: test_set_description

 def test_set_description(self):
     for dut in self.duts:
         text = random_string()
         intf = random_interface(dut)
         result = dut.api('interfaces').set_description(intf, text)
         self.assertTrue(result)
         config = dut.run_commands('show interfaces %s' % intf)
         config = config[0]['interfaces'][intf]
         self.assertEqual(config['description'], text)
开发者ID:CullyB,项目名称:pyeapi,代码行数:9,代码来源:test_api_interfaces.py


示例10: test_enable_with_single_command

    def test_enable_with_single_command(self):
        command = random_string()
        response = ['enable', command]

        self.connection.execute.return_value = {'result': list(response)}
        result = self.node.enable(command)

        self.connection.execute.assert_called_once_with(response, 'json')
        self.assertEqual(command, result[0]['result'])
开发者ID:GaryCarneiro,项目名称:pyeapi,代码行数:9,代码来源:test_client.py


示例11: test_set_description_negate

 def test_set_description_negate(self):
     for dut in self.duts:
         text = random_string()
         intf = random_interface(dut)
         dut.config(['interface %s' % intf, 'description %s' % text])
         result = dut.api('interfaces').set_description(intf, disable=True)
         self.assertTrue(result)
         config = dut.run_commands('show interfaces %s' % intf)
         config = config[0]['interfaces'][intf]
         self.assertEqual(config['description'], '')
开发者ID:arista-eosplus,项目名称:pyeapi,代码行数:10,代码来源:test_api_interfaces.py


示例12: test_set_name

 def test_set_name(self):
     for dut in self.duts:
         name = random_string(maxchar=20)
         vid = str(random_int(2, 4095))
         dut.config(['no vlan %s' % vid, 'vlan %s' % vid])
         result = dut.api('vlans').set_name(vid, name)
         self.assertTrue(result, 'dut=%s' % dut)
         config = dut.run_commands('show vlan')
         self.assertEqual(name, config[0]['vlans'][vid]['name'],
                          'dut=%s' % dut)
开发者ID:arista-eosplus,项目名称:pyeapi,代码行数:10,代码来源:test_api_vlans.py


示例13: test_default

 def test_default(self):
     for dut in self.duts:
         vid = str(random_int(2, 4095))
         name = random_string(maxchar=20)
         dut.config(['no vlan %s' % vid, 'vlan %s' % vid,
                     'vlan %s' % vid, 'name %s' % name])
         result = dut.api('vlans').default(vid)
         self.assertTrue(result, 'dut=%s' % dut)
         config = dut.run_commands('show vlan')
         self.assertNotIn(vid, config[0]['vlans'], 'dut=%s' % dut)
开发者ID:arista-eosplus,项目名称:pyeapi,代码行数:10,代码来源:test_api_vlans.py


示例14: test_add_trunk_group

 def test_add_trunk_group(self):
     for dut in self.duts:
         tg = random_string(maxchar=32)
         vid = str(random_int(2, 4095))
         dut.config(['no vlan %s' % vid, 'vlan %s' % vid, 'no trunk group'])
         result = dut.api('vlans').add_trunk_group(vid, tg)
         self.assertTrue(result, 'dut=%s' % dut)
         config = dut.run_commands('show vlan trunk group')
         self.assertIn(tg, config[0]['trunkGroups'][vid]['names'],
                       'dut=%s' % dut)
开发者ID:arista-eosplus,项目名称:pyeapi,代码行数:10,代码来源:test_api_vlans.py


示例15: test_set_trunk_groups_default

 def test_set_trunk_groups_default(self):
     for dut in self.duts:
         vid = str(random_int(2, 4094))
         tg = random_string()
         dut.config(['no vlan %s' % vid, 'vlan %s' % vid,
                     'trunk group %s' % tg])
         result = dut.api('vlans').set_trunk_groups(vid, default=True)
         self.assertTrue(result, 'dut=%s' % dut)
         cmd = 'show running-config section vlan %s' % vid
         config = dut.run_commands(cmd, 'text')
         self.assertNotIn('trunk group', config[0]['output'])
开发者ID:arista-eosplus,项目名称:pyeapi,代码行数:11,代码来源:test_api_vlans.py


示例16: test_config_single_command

    def test_config_single_command(self):
        for dut in self.duts:
            hostname = 'hostname %s' % random_string(5, 50)
            result = dut.config(hostname)
            self.assertIsInstance(result, list, 'dut=%s' % dut)
            self.assertEqual(len(result), 1, 'dut=%s' % dut)
            self.assertEqual(result[0], {}, 'dut=%s' % dut)

            result = dut.run_commands('show running-config | include %s$' %
                                      hostname, 'text')
            self.assertEqual(result[0]['output'].strip(), hostname)
开发者ID:CullyB,项目名称:pyeapi,代码行数:11,代码来源:test_client.py


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


示例18: test_set_hostname

 def test_set_hostname(self):
     for state in ['config', 'negate', 'default']:
         value = random_string()
         if state == 'config':
             cmds = 'hostname %s' % value
             func = function('set_hostname', value)
         elif state == 'negate':
             cmds = 'no hostname'
             func = function('set_hostname', disable=True)
         elif state == 'default':
             cmds = 'default hostname'
             func = function('set_hostname', value=value, default=True)
         self.eapi_positive_config_test(func, cmds)
开发者ID:arista-eosplus,项目名称:pyeapi,代码行数:13,代码来源:test_api_system.py


示例19: test_set_description

 def test_set_description(self):
     for dut in self.duts:
         text = random_string()
         dut.config(['no route-map TEST deny 10',
                     'route-map TEST deny 10'])
         api = dut.api('routemaps')
         self.assertNotIn('description %s' % text,
                          api.get_block('route-map TEST deny 10'))
         result = dut.api('routemaps').set_description('TEST', 'deny', 10,
                                                       text)
         self.assertTrue(result)
         self.assertIn('description %s' % text,
                       api.get_block('route-map TEST deny 10'))
开发者ID:dathelen,项目名称:pyeapi,代码行数:13,代码来源:test_api_routemaps.py


示例20: test_set_name

 def test_set_name(self):
     for state in ['config', 'negate', 'default']:
         vid = random_vlan()
         name = random_string()
         if state == 'config':
             cmds = ['vlan %s' % vid, 'name %s' % name]
             func = function('set_name', vid, name)
         elif state == 'negate':
             cmds = ['vlan %s' % vid, 'no name']
             func = function('set_name', vid)
         elif state == 'default':
             cmds = ['vlan %s' % vid, 'default name']
             func = function('set_name', vid, default=True)
         self.eapi_positive_config_test(func, cmds)
开发者ID:dathelen,项目名称:pyeapi,代码行数:14,代码来源:test_api_vlans.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python testlib.save_output函数代码示例发布时间:2022-05-27
下一篇:
Python testlib.next_block函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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