| OLD | NEW |
| 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 base64 | 5 import base64 |
| 6 from datetime import datetime | 6 from datetime import datetime |
| 7 import json | 7 import json |
| 8 import re | 8 import re |
| 9 | 9 |
| 10 from testing_utils import testing | 10 from testing_utils import testing |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 } | 255 } |
| 256 | 256 |
| 257 | 257 |
| 258 class GitRepositoryTest(TestCase): | 258 class GitRepositoryTest(TestCase): |
| 259 | 259 |
| 260 def setUp(self): | 260 def setUp(self): |
| 261 super(GitRepositoryTest, self).setUp() | 261 super(GitRepositoryTest, self).setUp() |
| 262 self.http_client_for_git = self.GetMockHttpClient() | 262 self.http_client_for_git = self.GetMockHttpClient() |
| 263 self.repo_url = 'https://repo.test' | 263 self.repo_url = 'https://repo.test' |
| 264 self.git_repo = gitiles_repository.GitilesRepository( | 264 self.git_repo = gitiles_repository.GitilesRepository( |
| 265 self.repo_url, self.http_client_for_git) | 265 self.http_client_for_git, self.repo_url) |
| 266 | 266 |
| 267 def testGitRepositoryPropertySetters(self): | 267 def testGitRepositoryPropertySetters(self): |
| 268 git_repo = gitiles_repository.GitilesRepository( | 268 git_repo = gitiles_repository.GitilesRepository(self.http_client_for_git) |
| 269 http_client=self.http_client_for_git) | |
| 270 git_repo.repo_url = 'https://repo' | 269 git_repo.repo_url = 'https://repo' |
| 271 self.assertEqual(git_repo.repo_url, 'https://repo') | 270 self.assertEqual(git_repo.repo_url, 'https://repo') |
| 272 self.assertEqual(git_repo.http_client, self.http_client_for_git) | 271 self.assertEqual(git_repo.http_client, self.http_client_for_git) |
| 273 | 272 |
| 274 def testEndingSlashInRepoUrl(self): | 273 def testEndingSlashInRepoUrl(self): |
| 275 git_repo1 = gitiles_repository.GitilesRepository( | 274 git_repo1 = gitiles_repository.GitilesRepository( |
| 276 self.repo_url, self.http_client_for_git) | 275 self.http_client_for_git, self.repo_url) |
| 277 self.assertEqual(self.repo_url, git_repo1.repo_url) | 276 self.assertEqual(self.repo_url, git_repo1.repo_url) |
| 278 | 277 |
| 279 git_repo2 = gitiles_repository.GitilesRepository( | 278 git_repo2 = gitiles_repository.GitilesRepository( |
| 280 '%s/' % self.repo_url, self.http_client_for_git) | 279 self.http_client_for_git, '%s/' % self.repo_url) |
| 281 self.assertEqual(self.repo_url, git_repo2.repo_url) | 280 self.assertEqual(self.repo_url, git_repo2.repo_url) |
| 282 | 281 |
| 283 def testMalformattedJsonReponse(self): | 282 def testMalformattedJsonReponse(self): |
| 284 self.http_client_for_git.SetResponseForUrl( | 283 self.http_client_for_git.SetResponseForUrl( |
| 285 '%s/+/%s?format=json' % (self.repo_url, 'aaa'), 'abcde{"a": 1}') | 284 '%s/+/%s?format=json' % (self.repo_url, 'aaa'), 'abcde{"a": 1}') |
| 286 self.assertRaisesRegexp( | 285 self.assertRaisesRegexp( |
| 287 Exception, re.escape('Response does not begin with )]}\'\n'), | 286 Exception, re.escape('Response does not begin with )]}\'\n'), |
| 288 self.git_repo.GetChangeLog, 'aaa') | 287 self.git_repo.GetChangeLog, 'aaa') |
| 289 | 288 |
| 290 def testGetChangeLog(self): | 289 def testGetChangeLog(self): |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 | 438 |
| 440 self.mock(gitiles_repository.GitilesRepository, | 439 self.mock(gitiles_repository.GitilesRepository, |
| 441 '_SendRequestForJsonResponse', _MockSendRequestForJsonResponse) | 440 '_SendRequestForJsonResponse', _MockSendRequestForJsonResponse) |
| 442 | 441 |
| 443 changelogs = self.git_repo.GetChangeLogs('0', '2') | 442 changelogs = self.git_repo.GetChangeLogs('0', '2') |
| 444 | 443 |
| 445 self.assertEqual(len(changelogs), 2) | 444 self.assertEqual(len(changelogs), 2) |
| 446 | 445 |
| 447 def testGetWrappedGitRepositoryClass(self): | 446 def testGetWrappedGitRepositoryClass(self): |
| 448 repo = gitiles_repository.GitilesRepository( | 447 repo = gitiles_repository.GitilesRepository( |
| 449 'http://repo_url', self.http_client_for_git) | 448 self.http_client_for_git, 'http://repo_url') |
| 450 | |
| 451 self.assertEqual(repo.repo_url, 'http://repo_url') | 449 self.assertEqual(repo.repo_url, 'http://repo_url') |
| OLD | NEW |