def test_should_open_set_shell_id(self, mock_session): expected_id = '0000' mock_instance = mock_session.return_value mock_instance.create.return_value = {'rsp:Shell': {'rsp:ShellId': expected_id}} mock_instance.command.return_value = {'rsp:CommandResponse': {'rsp:CommandId': '9999'}} shell = CommandShell('http://server:5985', 'username', 'password') shell.open() shell.run('unittest') args, kwargs = mock_instance.command.call_args self.assertEqual(expected_id, args[0].selectors['ShellId'])
def create_session(): """ shell = CommandShell('http://192.168.145.132:5985/wsman', 'Administrator', 'Pa55w0rd') """ shell = CommandShell('http://192.168.137.238:5985/wsman', 'Administrator', 'Pa55w0rd') shell.open() command_id = shell.run('ipconfig', ['/all']) (stdout, stderr, exit_code) = shell.receive(command_id) sys.stdout.write(stdout.strip() + '\r\n') shell.close() return None
def test_should_open_set_shell_id(self, mock_session): expected_id = '0000' mock_instance = mock_session.return_value mock_instance.create.return_value = { 'rsp:Shell': { 'rsp:ShellId': expected_id } } mock_instance.command.return_value = { 'rsp:CommandResponse': { 'rsp:CommandId': '9999' } } shell = CommandShell('http://server:5985', 'username', 'password') shell.open() shell.run('unittest') args, kwargs = mock_instance.command.call_args self.assertEqual(expected_id, args[0].selectors['ShellId'])