Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 1359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1370 ((['git', 'config', 'branch.feature.gerritserver'],), | 1370 ((['git', 'config', 'branch.feature.gerritserver'],), |
| 1371 'https://chromium-review.googlesource.com'), | 1371 'https://chromium-review.googlesource.com'), |
| 1372 ((['SetReview', 'chromium-review.googlesource.com', 123, | 1372 ((['SetReview', 'chromium-review.googlesource.com', 123, |
| 1373 {'Commit-Queue': 1}],), ''), | 1373 {'Commit-Queue': 1}],), ''), |
| 1374 ] | 1374 ] |
| 1375 # TODO(tandrii): consider testing just set-commit and set-commit --clear, | 1375 # TODO(tandrii): consider testing just set-commit and set-commit --clear, |
| 1376 # but without copy-pasting tons of expectations, as modifying them later is | 1376 # but without copy-pasting tons of expectations, as modifying them later is |
| 1377 # super tedious. | 1377 # super tedious. |
| 1378 self.assertEqual(0, git_cl.main(['set-commit', '-d'])) | 1378 self.assertEqual(0, git_cl.main(['set-commit', '-d'])) |
| 1379 | 1379 |
| 1380 def test_description_display(self): | |
| 1381 real_out = sys.stdout | |
|
tandrii(chromium)
2016/04/19 09:42:04
remove this
| |
| 1382 out = StringIO.StringIO() | |
| 1383 self.mock(git_cl.sys, 'stdout', out) | |
| 1384 self.mock(git_cl.Changelist, 'GetDescription', | |
| 1385 lambda *args: 'foobar') | |
| 1386 | |
| 1387 self.calls = [ | |
| 1388 ((['git', 'symbolic-ref', 'HEAD'],), 'feature'), | |
| 1389 ((['git', 'config', 'branch.feature.rietveldissue'],), '123123'), | |
| 1390 ((['git', 'config', 'rietveld.autoupdate'],), ''), | |
| 1391 ((['git', 'config', 'rietveld.server'],), ''), | |
| 1392 ((['git', 'config', 'rietveld.server'],), ''), | |
| 1393 ] | |
| 1394 self.assertEqual(0, git_cl.main(['description', '-d'])) | |
| 1395 self.assertEqual('foobar\n', out.getvalue()) | |
| 1396 | |
| 1397 def test_description_rietveld(self): | |
| 1398 real_out = sys.stdout | |
|
tandrii(chromium)
2016/04/19 09:42:04
ditto
| |
| 1399 out = StringIO.StringIO() | |
| 1400 self.mock(git_cl.sys, 'stdout', out) | |
| 1401 self.mock(git_cl.Changelist, 'GetDescription', | |
| 1402 lambda *args: 'foobar') | |
| 1403 | |
| 1404 self.calls = [ | |
| 1405 ((['git', 'symbolic-ref', 'HEAD'],), 'feature'), | |
| 1406 ((['git', 'config', 'branch.feature.rietveldissue'],), '123123'), | |
|
tandrii(chromium)
2016/04/19 09:42:04
this is wrong. This means that coincidentally loca
| |
| 1407 ((['git', 'config', 'rietveld.autoupdate'],), ''), | |
| 1408 ((['git', 'config', 'rietveld.server'],), ''), | |
| 1409 ((['git', 'config', 'rietveld.server'],), ''), | |
| 1410 ] | |
| 1411 self.assertEqual(0, git_cl.main([ | |
| 1412 'description', '-d', '-i', '123123', '-s', 'https://code.review.org' | |
|
tandrii(chromium)
2016/04/19 09:42:04
ah, this is outdated test.
martiniss
2016/04/25 22:33:06
Yup. Tests should be good to go now.
| |
| 1413 '--rietveld'])) | |
| 1414 self.assertEqual('foobar\n', out.getvalue()) | |
| 1415 | |
| 1416 | |
| 1417 | |
| 1380 | 1418 |
| 1381 if __name__ == '__main__': | 1419 if __name__ == '__main__': |
| 1382 git_cl.logging.basicConfig( | 1420 git_cl.logging.basicConfig( |
| 1383 level=git_cl.logging.DEBUG if '-v' in sys.argv else git_cl.logging.ERROR) | 1421 level=git_cl.logging.DEBUG if '-v' in sys.argv else git_cl.logging.ERROR) |
| 1384 unittest.main() | 1422 unittest.main() |
| OLD | NEW |