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


Python testlib.random_string函数代码示例

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


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


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