예제 #1
0
class AppTest(unittest.TestCase):
    def setUp(self):
        self.app = App()
        self.app.load_config_file('sessions.yaml')

    def test_telnet_session(self):
        session = self.app.telnet_session

        res = session.command('cd download; pwd')
        print(res)
        res = session.command('ls -lrt')
        print(res)

    def test_ssh_session(self):
        session = self.app.ssh_session

        # res = session.command('cd download; pwd')
        # print(res)
        res = session.command('^C')
        print(res)

        # res = session.command('ls -lrt')
        # print(res)

    def test_pick(self):
        self.app.ssh_session.command('ls')
        with open('test_pickle.txt', 'w') as f:
            cPickle.dump(self.app, f)

        app = cPickle.load(open('test_pickle.txt'))
        app.ssh_session.command('ls')
예제 #2
0
class AppTest(unittest.TestCase):
    def setUp(self):
        self.app = App()
        self.app.load_config_file('sessions.yaml')

    def test_multi_input(self):
        session = self.app.ssh_session

        session.command('cd {}'.format(os.getcwd()))
        res = session.command('python mulit_input.py',
                              prompt=[('Please input node password:'******'aaaa'), ('Please confirm \[y/n\]', 'n')])
        pprint(res)

    def test_sleep_input(self):
        session = self.app.ssh_session
        session.command('cd {}'.format(os.getcwd()))
        res = session.command('python sleep_input.py',
                              prompt=[('Please input node password:'******'aaaa'), ('Please confirm \[y/n\]', 'n')],
                              timeout=10)
        pprint(res)