コード例 #1
0
ファイル: shell_test.py プロジェクト: pombreda/bigitr
 def test_readShellOutputError(self):
     l = log.Log(self.ctx, 'Path/To/Git/repo2', None)
     retcode = shell.run(l, 'sh', '-c', 'echo bar; echo baz; echo foo >&2 ; exit 1', error=False)
     self.assertEqual(retcode, 1)
     self.assertEqual(l.lastOutput(), ('bar\nbaz\n', 'foo\n'))
     self.assertEqual(l.lastError(), 'foo\n')
     ao = mock.Mock()
     self.ctx.mails['Path/To/Git/repo2'].addOutput = ao
     l.mailLastOutput('broke')
     ao.assert_called_with('broke', 'bar\nbaz\n', 'foo\n')
コード例 #2
0
 def test_readShellOutputError(self):
     l = log.Log(self.ctx, 'Path/To/Git/repo2', None)
     retcode = shell.run(l,
                         'sh',
                         '-c',
                         'echo bar; echo baz; echo foo >&2 ; exit 1',
                         error=False)
     self.assertEqual(retcode, 1)
     self.assertEqual(l.lastOutput(), ('bar\nbaz\n', 'foo\n'))
     self.assertEqual(l.lastError(), 'foo\n')
     ao = mock.Mock()
     self.ctx.mails['Path/To/Git/repo2'].addOutput = ao
     l.mailLastOutput('broke')
     ao.assert_called_with('broke', 'bar\nbaz\n', 'foo\n')
コード例 #3
0
 def test_run(self):
     l = log.Log(self.ctx, 'Path/To/Git/repo2', None)
     retcode = shell.run(l, 'false', error=False)
     self.assertEqual(retcode, 1)
     l.close()
     thislog = '/'.join((self.logdir, 'repo2'))
     files = os.listdir(thislog)
     for filename in files:
         fileName = '/'.join((thislog, filename))
         logLines = gzip.GzipFile(fileName).readlines()
         nonLogLines = [x for x in logLines if not x.startswith('[')]
         self.assertEqual(len(nonLogLines), 0)
         self.assertTrue(
             logLines[-1].endswith(' COMPLETE with return code: 1\n'))
     self.assertEqual(self.logdata.getvalue(), '')
     self.logdata.truncate(0)
コード例 #4
0
ファイル: shell_test.py プロジェクト: pombreda/bigitr
 def test_run(self):
     l = log.Log(self.ctx, 'Path/To/Git/repo2', None)
     retcode = shell.run(l, 'false', error=False)
     self.assertEqual(retcode, 1)
     l.close()
     thislog = '/'.join((self.logdir, 'repo2'))
     files = os.listdir(thislog)
     for filename in files:
         fileName = '/'.join((thislog, filename))
         logLines = gzip.GzipFile(fileName).readlines()
         nonLogLines = [x for x in logLines if not x.startswith('[')]
         self.assertEqual(len(nonLogLines), 0)
         self.assertTrue(
             logLines[-1].endswith(' COMPLETE with return code: 1\n'))
     self.assertEqual(self.logdata.getvalue(), '')
     self.logdata.truncate(0)
コード例 #5
0
 def test_readShellOutputData(self):
     l = log.Log(self.ctx, 'Path/To/Git/repo2', None)
     retcode = shell.run(l, 'echo', 'foo')
     self.assertEqual(retcode, 0)
     self.assertEqual(l.lastOutput(), ('foo\n', ''))
コード例 #6
0
ファイル: shell_test.py プロジェクト: pombreda/bigitr
 def test_readShellOutputData(self):
     l = log.Log(self.ctx, 'Path/To/Git/repo2', None)
     retcode = shell.run(l, 'echo', 'foo')
     self.assertEqual(retcode, 0)
     self.assertEqual(l.lastOutput(), ('foo\n', ''))