Esempio n. 1
0
 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)
Esempio n. 2
0
 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)
Esempio n. 3
0
 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']})
Esempio n. 4
0
 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 &')
Esempio n. 5
0
 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)