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

Side by Side Diff: tests/git_cl_test.py

Issue 1901733003: git_cl: description fetching from code review servers. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Small whitespace. Created 4 years, 7 months 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
« no previous file with comments | « git_cl.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Unit tests for git_cl.py.""" 6 """Unit tests for git_cl.py."""
7 7
8 import os 8 import os
9 import StringIO 9 import StringIO
10 import stat 10 import stat
(...skipping 1363 matching lines...) Expand 10 before | Expand all | Expand 10 after
1374 ((['git', 'config', 'branch.feature.gerritserver'],), 1374 ((['git', 'config', 'branch.feature.gerritserver'],),
1375 'https://chromium-review.googlesource.com'), 1375 'https://chromium-review.googlesource.com'),
1376 ((['SetReview', 'chromium-review.googlesource.com', 123, 1376 ((['SetReview', 'chromium-review.googlesource.com', 123,
1377 {'Commit-Queue': 1}],), ''), 1377 {'Commit-Queue': 1}],), ''),
1378 ] 1378 ]
1379 # TODO(tandrii): consider testing just set-commit and set-commit --clear, 1379 # TODO(tandrii): consider testing just set-commit and set-commit --clear,
1380 # but without copy-pasting tons of expectations, as modifying them later is 1380 # but without copy-pasting tons of expectations, as modifying them later is
1381 # super tedious. 1381 # super tedious.
1382 self.assertEqual(0, git_cl.main(['set-commit', '-d'])) 1382 self.assertEqual(0, git_cl.main(['set-commit', '-d']))
1383 1383
1384 def test_description_display(self):
1385 out = StringIO.StringIO()
1386 self.mock(git_cl.sys, 'stdout', out)
1387
1388 class MockChangelist():
1389 def __init__(self, **kwargs):
1390 pass
1391 def GetIssue(self):
1392 return 1
1393 def GetDescription(self):
1394 return 'foo'
1395
1396 self.mock(git_cl, 'Changelist', MockChangelist)
1397
1398 self.assertEqual(0, git_cl.main(['description', '-d']))
1399 self.assertEqual('foo\n', out.getvalue())
1400
1401 def test_description_rietveld(self):
1402 out = StringIO.StringIO()
1403 self.mock(git_cl.sys, 'stdout', out)
1404 self.mock(git_cl.Changelist, 'GetDescription',
1405 lambda *args: 'foobar')
1406
1407 self.calls = [
1408 ((['git', 'config', 'rietveld.autoupdate'],), ''),
1409 ((['git', 'config', 'rietveld.server'],), ''),
1410 ((['git', 'config', 'rietveld.server'],), ''),
1411 ]
1412 self.assertEqual(0, git_cl.main([
1413 'description', 'https://code.review.org/123123', '-d', '--rietveld']))
1414 self.assertEqual('foobar\n', out.getvalue())
1415
1416 def test_description_gerrit(self):
1417 out = StringIO.StringIO()
1418 self.mock(git_cl.sys, 'stdout', out)
1419 self.mock(git_cl.Changelist, 'GetDescription',
1420 lambda *args: 'foobar')
1421
1422 self.assertEqual(0, git_cl.main([
1423 'description', 'https://code.review.org/123123', '-d', '--gerrit']))
1424 self.assertEqual('foobar\n', out.getvalue())
1425
1384 1426
1385 if __name__ == '__main__': 1427 if __name__ == '__main__':
1386 git_cl.logging.basicConfig( 1428 git_cl.logging.basicConfig(
1387 level=git_cl.logging.DEBUG if '-v' in sys.argv else git_cl.logging.ERROR) 1429 level=git_cl.logging.DEBUG if '-v' in sys.argv else git_cl.logging.ERROR)
1388 unittest.main() 1430 unittest.main()
OLDNEW
« no previous file with comments | « git_cl.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698