Chromium Code Reviews| Index: appengine/findit/lib/gitiles/test/repo_util_test.py |
| diff --git a/appengine/findit/lib/gitiles/test/repo_util_test.py b/appengine/findit/lib/gitiles/test/repo_util_test.py |
| index a5f62edc4efaa9d4f8f9f29ddb868d2338b3d11b..1ebb9beb1ff0b4435cc030b89f88c48f05826428 100644 |
| --- a/appengine/findit/lib/gitiles/test/repo_util_test.py |
| +++ b/appengine/findit/lib/gitiles/test/repo_util_test.py |
| @@ -4,6 +4,7 @@ |
| import json |
| import StringIO |
| +import subprocess |
| from testing_utils import testing |
| import textwrap |
| import urllib2 |
| @@ -133,3 +134,28 @@ class RepoUtilTest(testing.AppengineTestCase): |
| reverted_revision = repo_util.GetRevertedRevision(message) |
| self.assertIsNone(reverted_revision) |
| + |
| + def testGetLocalGitCommandOutput(self): |
| + class _MockProcess(object): |
| + def __init__(self, command, *_): |
| + self.command = command |
| + |
| + def communicate(self, *_): |
| + return self.command, 'dummy' |
| + |
| + @property |
| + def returncode(self): |
|
wrengr
2016/11/01 20:26:53
-> ``return 1 if self.command == 'dummy' else 0``
Sharu Jiang
2016/11/05 01:18:16
Done.
|
| + if self.command == 'dummy': |
| + return 1 |
| + |
| + return 0 |
| + |
| + def _MockPopen(command, **_): |
| + return _MockProcess(command) |
| + |
| + self.mock(subprocess, 'Popen', _MockPopen) |
|
wrengr
2016/11/01 20:26:53
-> ``self.mock(subprocess, 'Popen',
lambd
Sharu Jiang
2016/11/05 01:18:16
Done.
|
| + output = repo_util.GetCommandOutput('command') |
| + self.assertEqual(output, 'command') |
| + |
| + output = repo_util.GetCommandOutput('dummy') |
| + self.assertEqual(output, None) |