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

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

Issue 2344443005: [Findit] Factoring the gitiles (etc) stuff out into its own directory (Closed)
Patch Set: reordering imports Created 4 years, 2 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/test/change_log_test.py ('k') | appengine/findit/common/test/dependency_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: appengine/findit/common/test/chrome_dependency_fetcher_test.py
diff --git a/appengine/findit/common/test/chrome_dependency_fetcher_test.py b/appengine/findit/common/test/chrome_dependency_fetcher_test.py
index 472a9bccb1534103515d48bc531154b924b0c27f..2e5834766b32c38c65a0700d7f29eebea28c5f90 100644
--- a/appengine/findit/common/test/chrome_dependency_fetcher_test.py
+++ b/appengine/findit/common/test/chrome_dependency_fetcher_test.py
@@ -9,14 +9,23 @@ from testing_utils import testing
from common import chrome_dependency_fetcher
from common import deps_parser
-from common import git_repository
-from common import repository
from common import retry_http_client
from common import http_client_appengine
from common.dependency import Dependency, DependencyRoll
+from lib.gitiles.git_repository import GitRepository
+from lib.gitiles import gitiles_repository
-class DummyGitRepository(repository.Repository):
+class MockGitilesRepository(GitRepository):
+ """A class for mocking GitilesRepository.
+
+ N.B., in order to use this class for mocking, every module we want to
+ test with a mock GitilesRepository must not import that class directly.
+ Instead they must import the gitiles_repository module and rely on
+ dynamic dispatch to resolve the GitilesRepository attribute. Otherwise
+ those modules will hold direct links to the real GitilesRepository
+ class, and so won't dispatch into this mock class for our unit tests."""
+
RESPONSES = {}
def __init__(self, *_):
@@ -30,15 +39,15 @@ class ChromiumDEPSTest(testing.AppengineTestCase):
DEPS_GIT = '.DEPS.git'
DEPS = 'DEPS'
deps_downloader = chrome_dependency_fetcher.DEPSDownloader(
- DummyGitRepository())
+ MockGitilesRepository())
chrome_dep_fetcher = chrome_dependency_fetcher.ChromeDependencyFetcher(
- DummyGitRepository())
+ MockGitilesRepository())
def testUseDEPS_GIT(self):
revision = 'abc'
expected_content = '.DEPS.git content'
- DummyGitRepository.RESPONSES = {
+ MockGitilesRepository.RESPONSES = {
self.DEPS_GIT: {
revision: expected_content
},
@@ -55,7 +64,7 @@ class ChromiumDEPSTest(testing.AppengineTestCase):
revision = 'abc'
expected_content = 'DEPS test'
- DummyGitRepository.RESPONSES = {
+ MockGitilesRepository.RESPONSES = {
self.DEPS_GIT: {
revision: '.DEPS.git content'
},
@@ -64,7 +73,7 @@ class ChromiumDEPSTest(testing.AppengineTestCase):
},
}
- self.mock(git_repository, 'GitRepository', DummyGitRepository)
+ self.mock(gitiles_repository, 'GitilesRepository', MockGitilesRepository)
content = self.deps_downloader.Load(
'https://src.git', revision, 'DEPS')
@@ -74,13 +83,13 @@ class ChromiumDEPSTest(testing.AppengineTestCase):
revision = 'abc'
expected_content = 'DEPS test'
- DummyGitRepository.RESPONSES = {
+ MockGitilesRepository.RESPONSES = {
self.DEPS: {
revision: expected_content
},
}
- self.mock(git_repository, 'GitRepository', DummyGitRepository)
+ self.mock(gitiles_repository, 'GitilesRepository', MockGitilesRepository)
content = self.deps_downloader.Load(
'https://src.git', revision, 'NONEXISTENT_DEPS')
@@ -90,7 +99,7 @@ class ChromiumDEPSTest(testing.AppengineTestCase):
revision = 'abc'
expected_content = 'slave DEPS content'
- DummyGitRepository.RESPONSES = {
+ MockGitilesRepository.RESPONSES = {
self.DEPS_GIT: {
revision: '.DEPS.git content'
},
@@ -99,14 +108,14 @@ class ChromiumDEPSTest(testing.AppengineTestCase):
},
}
- self.mock(git_repository, 'GitRepository', DummyGitRepository)
+ self.mock(gitiles_repository, 'GitilesRepository', MockGitilesRepository)
content = self.deps_downloader.Load(
'https://src.git', revision, 'slave.DEPS')
self.assertEqual(expected_content, content)
def testFailedToPullDEPSFile(self):
- DummyGitRepository.RESPONSES = {}
+ MockGitilesRepository.RESPONSES = {}
self.assertRaisesRegexp(Exception, 'Failed to pull DEPS file.',
self.deps_downloader.Load,
@@ -120,7 +129,7 @@ class ChromiumDEPSTest(testing.AppengineTestCase):
self.mock(http_client_appengine.HttpClientAppengine, '_Get', _MockGet)
deps_downloader = chrome_dependency_fetcher.DEPSDownloader(
- git_repository.GitRepository(
+ gitiles_repository.GitilesRepository(
http_client=http_client_appengine.HttpClientAppengine()))
content = deps_downloader.Load(
'http://chrome-internal', '50.0.1234.0', 'DEPS')
@@ -190,7 +199,7 @@ class ChromiumDEPSTest(testing.AppengineTestCase):
child2_dep.SetParent(root_dep)
grand_child1.SetParent(child1_dep)
- self.mock(git_repository, 'GitRepository', DummyGitRepository)
+ self.mock(gitiles_repository, 'GitilesRepository', MockGitilesRepository)
self.mock(deps_parser, 'UpdateDependencyTree', DummyUpdateDependencyTree)
dependency_dict = self.chrome_dep_fetcher.GetDependency(
« no previous file with comments | « appengine/findit/common/test/change_log_test.py ('k') | appengine/findit/common/test/dependency_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698