예제 #1
0
파일: cli.py 프로젝트: jungle-boogie/ntfy
 def test_runcmd(self, mock_call):
     mock_call.return_value = 0
     args = MagicMock()
     args.longer_than = 0
     args.command = ['true']
     self.assertEqual('"true" succeeded in 0:00 minutes',
                      run_cmd(args))
예제 #2
0
 def test_longerthan(self, mock_Popen):
     mock_Popen.return_value = process_mock()
     args = MagicMock()
     args.longer_than = 1
     args.command = ['true']
     args.pid = None
     args.unfocused_only = False
     self.assertEqual((None, None), run_cmd(args))
예제 #3
0
파일: test_cli.py 프로젝트: dixudx/ntfy
 def test_longerthan(self, mock_call):
     mock_call.return_value = 0
     args = MagicMock()
     args.longer_than = 1
     args.command = ['true']
     args.pid = None
     args.unfocused_only = False
     self.assertEqual(None, run_cmd(args))
예제 #4
0
파일: test_cli.py 프로젝트: dixudx/ntfy
 def test_default(self, mock_call):
     mock_call.return_value = 0
     args = MagicMock()
     args.longer_than = -1
     args.command = ['true']
     args.pid = None
     args.unfocused_only = False
     self.assertEqual('"true" succeeded in 0:00 minutes', run_cmd(args))
예제 #5
0
파일: test_cli.py 프로젝트: far1974/ntfy
 def test_longerthan(self, mock_call):
     mock_call.return_value = 0
     args = MagicMock()
     args.longer_than = 1
     args.command = ['true']
     args.pid = None
     args.unfocused_only = False
     self.assertEqual(None, run_cmd(args))
예제 #6
0
파일: test_cli.py 프로젝트: far1974/ntfy
 def test_default(self, mock_call):
     mock_call.return_value = 0
     args = MagicMock()
     args.longer_than = -1
     args.command = ['true']
     args.pid = None
     args.unfocused_only = False
     self.assertEqual('"true" succeeded in 0:00 minutes', run_cmd(args))
예제 #7
0
 def test_failure(self, mock_Popen):
     mock_Popen.return_value = process_mock(42)
     args = MagicMock()
     args.longer_than = -1
     args.command = ['false']
     args.pid = None
     args.unfocused_only = False
     self.assertEqual(('"false" failed (code 42) in 0:00 minutes', 42),
                      run_cmd(args))
예제 #8
0
 def test_watch_pid(self, mock_process):
     mock_process.return_value.pid = 1
     mock_process.return_value.create_time.return_value = time()
     mock_process.return_value.cmdline.return_value = ['cmd']
     args = MagicMock()
     args.pid = 1
     args.unfocused_only = False
     self.assertEqual('PID[1]: "cmd" finished in 0:00 minutes',
                      run_cmd(args)[0])
예제 #9
0
 def test_formatter_failure(self):
     args = MagicMock()
     args.pid = None
     args.command = None
     args.formatter = ("false", 1, 10)
     args.longer_than = -1
     args.unfocused_only = False
     self.assertEqual(('"false" failed (code 1) in 0:10 minutes', 1),
                      run_cmd(args))
예제 #10
0
 def test_formatter(self):
     args = MagicMock()
     args.pid = None
     args.command = None
     args.formatter = ("true", 0, 65)
     args.longer_than = -1
     args.unfocused_only = False
     self.assertEqual(('"true" succeeded in 1:05 minutes', 0),
                      run_cmd(args))
예제 #11
0
파일: test_cli.py 프로젝트: dixudx/ntfy
 def test_watch_pid(self, mock_process):
     mock_process.return_value.pid = 1
     mock_process.return_value.create_time.return_value = time()
     mock_process.return_value.cmdline.return_value = ['cmd']
     args = MagicMock()
     args.pid = 1
     args.unfocused_only = False
     self.assertEqual('PID[1]: "cmd" finished in 0:00 minutes',
                      run_cmd(args))
예제 #12
0
 def test_default(self, mock_Popen):
     mock_Popen.return_value = process_mock()
     args = MagicMock()
     args.longer_than = -1
     args.command = ['true']
     args.pid = None
     args.unfocused_only = False
     args.hide_command = False
     self.assertEqual(('"true" succeeded in 0:00 minutes', 0),
                      run_cmd(args))
예제 #13
0
 def test_emoji(self, mock_call):
     mock_call.return_value = 0
     args = MagicMock()
     args.longer_than = -1
     args.command = ['true']
     args.pid = None
     args.no_emoji = False
     args.unfocused_only = False
     self.assertEqual((':white_check_mark: "true" succeeded in 0:00 minutes', 0),
                      run_cmd(args))
예제 #14
0
파일: test_cli.py 프로젝트: oz123/ntfy
 def test_emoji(self, mock_call):
     mock_call.return_value = 0
     args = MagicMock()
     args.longer_than = -1
     args.command = ['true']
     args.pid = None
     args.no_emoji = False
     args.unfocused_only = False
     self.assertEqual((':white_check_mark: "true" succeeded in 0:00 minutes', 0),
                      run_cmd(args))
예제 #15
0
 def test_stderr(self, mock_Popen):
     mock_Popen.return_value = process_mock(stderr='error')
     args = MagicMock()
     args.longer_than = -1
     args.command = ['true']
     args.pid = None
     args.unfocused_only = False
     # not actually used
     args.stdout = False
     args.stderr = True
     self.assertEqual(('"true" succeeded in 0:00 minutes:\nerror', 0),
                      run_cmd(args))
예제 #16
0
 def test_failure_stdout_and_stderr(self, mock_Popen):
     mock_Popen.return_value = process_mock(1,
                                            stdout='output',
                                            stderr='error')
     args = MagicMock()
     args.longer_than = -1
     args.command = ['true']
     args.pid = None
     args.unfocused_only = False
     # not actually used
     args.stdout = True
     args.stderr = True
     self.assertEqual(
         ('"true" failed (code 1) in 0:00 minutes:\noutputerror', 1),
         run_cmd(args))