Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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))
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))
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)
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)
node = pyeapi.client.connect_to('test1')
kwargs = dict(host='192.168.1.16', username='eapi',
password='password', port=None, key_file=None,
cert_file=None, ca_file=None, timeout=60)
transport.assert_called_once_with(**kwargs)
self.assertEqual(node._enablepwd, 'enablepwd')
def test_missing_connection_raises_attribute_error(self):
with self.assertRaises(AttributeError):
pyeapi.client.connect_to('invalid')