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