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

Unified Diff: appengine/findit/common/test/git_repository_test.py

Issue 1957653002: [Findit] Pull changelogs in batch. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: 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 side-by-side diff with in-line comments
Download patch
Index: appengine/findit/common/test/git_repository_test.py
diff --git a/appengine/findit/common/test/git_repository_test.py b/appengine/findit/common/test/git_repository_test.py
index a0991742638da9b6fac6acdb7840e21c327aed83..b2d9ff11e59078550469d654aa315056595988b9 100644
--- a/appengine/findit/common/test/git_repository_test.py
+++ b/appengine/findit/common/test/git_repository_test.py
@@ -567,35 +567,37 @@ class GitRepositoryTest(testing.AppengineTestCase):
actual_commits = self.git_repo.GetCommitsBetweenRevisions('0', '3', n=2)
self.assertEqual(expected_commits, actual_commits)
- def _MockGetCommitsBetweenRevisions(self, *_):
- return ['2', '1']
-
def testGetChangeLogs(self):
- def _MockGetChangeLog(*_):
- return ChangeLog.FromDict(DUMMY_CHANGELOG_JSON)
+ def _MockSendRequestForJsonResponse(*_):
+ return {'log': [json.loads(COMMIT_LOG[5:])]}
- self.mock(git_repository.GitRepository, 'GetCommitsBetweenRevisions',
- self._MockGetCommitsBetweenRevisions)
- self.mock(git_repository.GitRepository, 'GetChangeLog',
- _MockGetChangeLog)
+ self.mock(git_repository.GitRepository, '_SendRequestForJsonResponse',
+ _MockSendRequestForJsonResponse)
changelogs = self.git_repo.GetChangeLogs('0', '2')
- self.assertEqual(len(changelogs), 2)
- self.assertEqual([changelogs[0].ToDict(), changelogs[1].ToDict()],
- [DUMMY_CHANGELOG_JSON, DUMMY_CHANGELOG_JSON])
+ self.assertEqual(len(changelogs), 1)
+ self.assertEqual(changelogs[0].ToDict(), EXPECTED_CHANGE_LOG_JSON)
- def testGetChangeLogsFailToGetChangeLog(self):
+ def testGetChangeLogsNextPage(self):
+ log1 = json.loads(COMMIT_LOG[5:])
+ log1['commit'] = 'first_commit'
+ log2 = log1.copy()
+ log2['commit'] = 'next_page_commit'
- def _MockGetChangeLog(*_):
- return None
+ def _MockSendRequestForJsonResponse(*args, **_):
+ url = args[1]
stgao 2016/05/06 06:59:18 Can we expand the arguments above instead?
Sharu Jiang 2016/05/06 17:46:12 Done.
+ if 'next' in url:
+ return {'log': [log2]}
+
+ return {'log': [log1], 'next': 'next_page_commit'}
+
+ self.mock(git_repository.GitRepository, '_SendRequestForJsonResponse',
+ _MockSendRequestForJsonResponse)
+
+ changelogs = self.git_repo.GetChangeLogs('0', '2')
+
+ self.assertEqual(len(changelogs), 2)
- self.mock(git_repository.GitRepository, 'GetCommitsBetweenRevisions',
- self._MockGetCommitsBetweenRevisions)
- self.mock(git_repository.GitRepository, 'GetChangeLog',
- _MockGetChangeLog)
- self.assertRaisesRegexp(
- Exception, 'Failed to pull changelog for revision 2',
- self.git_repo.GetChangeLogs, '0', '2')
« appengine/findit/common/git_repository.py ('K') | « appengine/findit/common/git_repository.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698