1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
__author__ = "jnpr-community-netdev"
try:
import unittest2 as unittest
except ImportError:
import unittest
import yaml
class __test(object):
@classmethod
def setUpClass(self):
from jnpr.junos import Device
with open("config.yaml", "r") as fyaml:
cfg = yaml.safe_load(fyaml)
self.dev = Device(**cfg)
self.dev.open()
@classmethod
def tearDownClass(self):
self.dev.close()
def test_shell_run(self):
from jnpr.junos.utils.start_shell import StartShell
with StartShell(self.dev) as sh:
output = sh.run("pwd")
self.assertTrue(output[0])
def test_shell_run_with_sleep(self):
from jnpr.junos.utils.start_shell import StartShell
with StartShell(self.dev) as sh:
output = sh.run("hostname", sleep=2)
self.assertTrue(output[0])
def test_shell_run_shell_type_ssh(self):
from jnpr.junos.utils.start_shell import StartShell
with StartShell(self.dev, shell_type="ssh") as sh:
output = sh.run("hostname", sleep=2)
self.assertTrue(output[0])
def test_shell_run_shell_type_csh(self):
from jnpr.junos.utils.start_shell import StartShell
with StartShell(self.dev, shell_type="csh") as sh:
output = sh.run("hostname", sleep=2)
self.assertTrue(output[0])
|