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

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: Fix nits. 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
« no previous file with comments | « appengine/findit/common/git_repository.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..5018075b57fa5b45832c851c0223797b30b7652b 100644
--- a/appengine/findit/common/test/git_repository_test.py
+++ b/appengine/findit/common/test/git_repository_test.py
@@ -567,35 +567,35 @@ 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 _MockSendRequestForJsonResponse(*_, **kargs):
+ self.assertTrue(bool(kargs))
+ return {'log': [json.loads(COMMIT_LOG[5:])]}
- def _MockGetChangeLog(*_):
- return ChangeLog.FromDict(DUMMY_CHANGELOG_JSON)
-
- 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(_, url, **kargs):
+ self.assertTrue(bool(kargs))
+ if 'next' in url:
+ return {'log': [log2]}
- self.mock(git_repository.GitRepository, 'GetCommitsBetweenRevisions',
- self._MockGetCommitsBetweenRevisions)
- self.mock(git_repository.GitRepository, 'GetChangeLog',
- _MockGetChangeLog)
+ return {'log': [log1], 'next': 'next_page_commit'}
- self.assertRaisesRegexp(
- Exception, 'Failed to pull changelog for revision 2',
- self.git_repo.GetChangeLogs, '0', '2')
+ self.mock(git_repository.GitRepository, '_SendRequestForJsonResponse',
+ _MockSendRequestForJsonResponse)
+
+ changelogs = self.git_repo.GetChangeLogs('0', '2')
+
+ self.assertEqual(len(changelogs), 2)
« no previous file with comments | « appengine/findit/common/git_repository.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698