Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(413)

Side by Side Diff: appengine/findit/lib/gitiles/test/repo_util_test.py

Issue 2432113002: [Findit] Add local_git_repository (Closed)
Patch Set: Rebase. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import json 5 import json
6 import StringIO 6 import StringIO
7 import subprocess
7 from testing_utils import testing 8 from testing_utils import testing
8 import textwrap 9 import textwrap
9 import urllib2 10 import urllib2
10 11
11 from lib.gitiles import repo_util 12 from lib.gitiles import repo_util
12 13
13 14
14 class RepoUtilTest(testing.AppengineTestCase): 15 class RepoUtilTest(testing.AppengineTestCase):
15 16
16 def testExtractCommitPositionAndCodeReviewUrl(self): 17 def testExtractCommitPositionAndCodeReviewUrl(self):
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 def testGetRevertedRevisionNoRevertedCL(self): 127 def testGetRevertedRevisionNoRevertedCL(self):
127 message = ( 128 message = (
128 'Test for not revert cl\n\n' 129 'Test for not revert cl\n\n'
129 'TBR=test@chromium.org\nNOPRESUBMIT=true\n' 130 'TBR=test@chromium.org\nNOPRESUBMIT=true\n'
130 'NOTREECHECKS=true\nNOTRY=true\nBUG=424661\n\n' 131 'NOTREECHECKS=true\nNOTRY=true\nBUG=424661\n\n'
131 'Review URL: https://codereview.chromium.org/1161773008\n\n' 132 'Review URL: https://codereview.chromium.org/1161773008\n\n'
132 'Cr-Commit-Position: refs/heads/master@{#332062}\n') 133 'Cr-Commit-Position: refs/heads/master@{#332062}\n')
133 134
134 reverted_revision = repo_util.GetRevertedRevision(message) 135 reverted_revision = repo_util.GetRevertedRevision(message)
135 self.assertIsNone(reverted_revision) 136 self.assertIsNone(reverted_revision)
137
138 def testGetLocalGitCommandOutput(self):
139 class _MockProcess(object):
140 def __init__(self, command, *_):
141 self.command = command
142
143 def communicate(self, *_):
144 return self.command, 'dummy'
145
146 @property
147 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.
148 if self.command == 'dummy':
149 return 1
150
151 return 0
152
153 def _MockPopen(command, **_):
154 return _MockProcess(command)
155
156 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.
157 output = repo_util.GetCommandOutput('command')
158 self.assertEqual(output, 'command')
159
160 output = repo_util.GetCommandOutput('dummy')
161 self.assertEqual(output, None)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698