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]
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_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')
self.assertEqual(cfg['enablepwd'], 'enablepwd')
def test_load_config_empty_conf(self):
conf = get_fixture('empty.conf')
pyeapi.client.load_config(filename=conf)
conns = pyeapi.client.config.connections
self.assertEqual(conns, ['localhost'])
def test_load_config_env_path(self):
os.environ['EAPI_CONF'] = get_fixture('env_path.conf')
pyeapi.client.config.autoload()
self.assertIn('connection:env_path', pyeapi.client.config.sections())