def test_process_error(self): launcher = LauncherMock() request = RequestMock() request.json = {'not_a_program': 'never_mind'} self.assertFalse(launcher.process(request)) self.assertFalse(hasattr(launcher, 'executed_command')) self.assertEqual(launcher.error, 400)
def test_process_error(self): commandLine = CommandLineMock() request = RequestMock() request.json = {'not_a_program': 'never_mind'} self.assertFalse(commandLine.process(request)) self.assertFalse(hasattr(commandLine, 'executed_command')) self.assertEqual(commandLine.error, 400)
def test_process_and_execute(self): commandLine = CommandLineMock() request = RequestMock() request.json = {'command': 'ps -ef'} self.assertTrue(commandLine.process(request)) self.assertEqual(commandLine.executed_command, ['ps', '-ef']) self.assertEqual(commandLine.result, {'stdout': ['line1', 'line2'], 'stderr': ['error1', 'error2']})
def test_process_and_execute(self): self.maxDiff = 1000 ps = PsMock() request = RequestMock() self.assertTrue(ps.process(request)) self.assertEqual(ps.executed_command, ['ps', '-ef']) self.assertEqual( ps.result, { 'processes': [{ 'uid': 'root', 'pid': '1', 'ppid': '0', 'c': '0', 'stime': '18:17', 'tty': '?', 'time': '00:00:01', 'cmd': '/sbin/init splash' }, { 'uid': 'tanguy', 'pid': '1662', 'ppid': '1133', 'c': '0', 'stime': '18:18', 'tty': '?', 'time': '00:00:00', 'cmd': '/usr/lib/x86_64-linux-gnu/indicator-bluetooth/indicator-bluetooth-service' }] })
def test_process_and_execute(self): launcher = LauncherMock() request = RequestMock() request.json = {'program': 'kodi'} self.assertTrue(launcher.process(request)) self.assertEqual(launcher.executed_command, 'kodi &')
def test_process_without_json(self): launcher = Launcher() request = RequestMock() self.assertFalse(launcher.process(request)) self.assertEqual(launcher.error, 400)
def test_process_with_json(self): ps = Ps() request = RequestMock() request.json = {'command': 'ps -ef'} self.assertFalse(ps.process(request)) self.assertEqual(ps.error, 400)
def test_process_without_json(self): commandLine = CommandLine() request = RequestMock() self.assertFalse(commandLine.process(request)) self.assertEqual(commandLine.error, 400)