本文整理汇总了Python中testlib.get_fixture函数的典型用法代码示例。如果您正苦于以下问题:Python get_fixture函数的具体用法?Python get_fixture怎么用?Python get_fixture使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_fixture函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: 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')
示例2: test_load_config
def test_load_config(self):
conf = get_fixture('eapi.conf')
pyeapi.client.load_config(conf)
self.assertEqual(len(pyeapi.client.config.sections()), 3)
for name in ['localhost', 'test1', 'test2']:
name = 'connection:%s' % name
self.assertIn(name, pyeapi.client.config.sections())
示例3: test_node_returns_startup_config
def test_node_returns_startup_config(self):
node = pyeapi.client.Node(None)
get_config_mock = Mock(name='get_config')
config = open(get_fixture('running_config.text')).read()
get_config_mock.return_value = config
node.get_config = get_config_mock
self.assertIsInstance(node.startup_config, str)
示例4: test_node_returns_cached_startup_confgi
def test_node_returns_cached_startup_confgi(self):
node = pyeapi.client.Node(None)
config_file = open(get_fixture('running_config.text'))
config = config_file.read()
config_file.close()
node._startup_config = config
self.assertEqual(node.startup_config, config)
示例5: test_load_config_for_connection_with_filename
def test_load_config_for_connection_with_filename(self):
conf = get_fixture('eapi.conf')
pyeapi.client.load_config(filename=conf)
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')
示例6: setUp
def setUp(self):
pyeapi.client.load_config(filename=get_fixture('dut.conf'))
config = pyeapi.client.config
self.duts = list()
for name in config.sections():
if name.startswith('connection:') and 'localhost' not in name:
name = name.split(':')[1]
self.duts.append(pyeapi.client.connect_to(name))
示例7: test_connect_to_with_config
def test_connect_to_with_config(self):
transport = Mock()
with patch.dict(pyeapi.client.TRANSPORTS, {'https': transport}):
conf = get_fixture('eapi.conf')
pyeapi.client.load_config(filename=conf)
pyeapi.client.connect_to('test1')
kwargs = dict(host='192.168.1.16', username='eapi',
password='password', port=None)
transport.assert_called_once_with(**kwargs)
示例8: test_connect_return_node
def test_connect_return_node(self):
transport = Mock()
with patch.dict(pyeapi.client.TRANSPORTS, {'https': transport}):
conf = get_fixture('eapi.conf')
pyeapi.client.load_config(filename=conf)
node = pyeapi.client.connect(host='192.168.1.16', username='eapi',
password='password', port=None,
timeout=60, return_node=True)
kwargs = dict(host='192.168.1.16', username='eapi',
password='password', port=None, timeout=60)
transport.assert_called_once_with(**kwargs)
self.assertIsNone(node._enablepwd)
示例9: setUp
def setUp(self):
pyeapi.client.load_config(filename=get_fixture('dut.conf'))
config = pyeapi.client.config
self.duts = list()
for name in config.sections():
if name.startswith('connection:') and 'localhost' not in name:
name = name.split(':')[1]
dut = pyeapi.client.connect_to(name)
self.duts.append(dut)
if dut._enablepwd is not None:
# If enable password defined for dut, set the
# enable password on the dut and clear it on tearDown
dut.config("enable secret %s" % dut._enablepwd)
示例10: __init__
def __init__(self, *args, **kwargs):
super(TestApiIpinterfaces, self).__init__(*args, **kwargs)
self.instance = pyeapi.api.ipinterfaces.instance(None)
self.config = open(get_fixture('running_config.text')).read()
示例11: __init__
def __init__(self, *args, **kwargs):
super(TestApiStaticroute, self).__init__(*args, **kwargs)
self.instance = pyeapi.api.staticroute.StaticRoute(None)
self.config = open(get_fixture('running_config.text')).read()
示例12: test_hosts_for_tag_returns_names
def test_hosts_for_tag_returns_names(self):
conf = get_fixture('eapi.conf')
pyeapi.client.load_config(conf)
result = pyeapi.client.hosts_for_tag('tag1')
self.assertEqual(sorted(['test1', 'test2']), sorted(result))
示例13: test_config_for_replaces_host_w_name
def test_config_for_replaces_host_w_name(self):
conf = get_fixture('nohost.conf')
pyeapi.client.load_config(conf)
cfg = pyeapi.config_for('test')
self.assertEqual(cfg['host'], 'test')
示例14: get_running_config
def get_running_config():
return get_fixture('running_config.text')
示例15: __init__
def __init__(self, *args, **kwargs):
super(TestApiSwitchports, self).__init__(*args, **kwargs)
self.instance = pyeapi.api.switchports.instance(None)
self.config = open(get_fixture('running_config.text')).read()