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

Side by Side Diff: appengine/findit/common/test/chrome_dependency_fetcher_test.py

Issue 2605943002: Removing the mutation in the factories for getting dep repositories (Closed)
Patch Set: Added the Factory method to CachedGitilesRepository Created 3 years, 11 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 unified diff | Download patch
OLDNEW
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 import collections 6 import collections
7 7
8 from testing_utils import testing 8 from testing_utils import testing
9 9
10 from common import chrome_dependency_fetcher 10 from common import chrome_dependency_fetcher
(...skipping 17 matching lines...) Expand all
28 28
29 RESPONSES = {} 29 RESPONSES = {}
30 30
31 def __init__(self, *_): 31 def __init__(self, *_):
32 pass 32 pass
33 33
34 def GetSource(self, path, revision): 34 def GetSource(self, path, revision):
35 return self.RESPONSES.get(path, {}).get(revision, None) 35 return self.RESPONSES.get(path, {}).get(revision, None)
36 36
37 37
38 def MockGitilesRepositoryFactory(repo_url):
39 """A factory for creating ``MockGitilesRepository`` objects."""
40 return MockGitilesRepository(repo_url)
41
42
38 class ChromiumDEPSTest(testing.AppengineTestCase): 43 class ChromiumDEPSTest(testing.AppengineTestCase):
39 DEPS_GIT = '.DEPS.git' 44 DEPS_GIT = '.DEPS.git'
40 DEPS = 'DEPS' 45 DEPS = 'DEPS'
41 deps_downloader = chrome_dependency_fetcher.DEPSDownloader( 46 deps_downloader = chrome_dependency_fetcher.DEPSDownloader(
42 MockGitilesRepository()) 47 MockGitilesRepositoryFactory)
43 chrome_dep_fetcher = chrome_dependency_fetcher.ChromeDependencyFetcher( 48 chrome_dep_fetcher = chrome_dependency_fetcher.ChromeDependencyFetcher(
44 MockGitilesRepository()) 49 MockGitilesRepositoryFactory)
45 50
46 def testUseDEPS_GIT(self): 51 def testUseDEPS_GIT(self):
47 revision = 'abc' 52 revision = 'abc'
48 expected_content = '.DEPS.git content' 53 expected_content = '.DEPS.git content'
49 54
50 MockGitilesRepository.RESPONSES = { 55 MockGitilesRepository.RESPONSES = {
51 self.DEPS_GIT: { 56 self.DEPS_GIT: {
52 revision: expected_content 57 revision: expected_content
53 }, 58 },
54 self.DEPS: { 59 self.DEPS: {
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 'https://src.git', 'abc', 'DEPS') 127 'https://src.git', 'abc', 'DEPS')
123 128
124 def testDEPSDownloaderForChromeVersion(self): 129 def testDEPSDownloaderForChromeVersion(self):
125 130
126 def _MockGet(*_): 131 def _MockGet(*_):
127 return 200, base64.b64encode('Dummy DEPS content') 132 return 200, base64.b64encode('Dummy DEPS content')
128 133
129 self.mock(http_client_appengine.HttpClientAppengine, '_Get', _MockGet) 134 self.mock(http_client_appengine.HttpClientAppengine, '_Get', _MockGet)
130 135
131 deps_downloader = chrome_dependency_fetcher.DEPSDownloader( 136 deps_downloader = chrome_dependency_fetcher.DEPSDownloader(
132 gitiles_repository.GitilesRepository( 137 lambda repo_url: gitiles_repository.GitilesRepository(
133 http_client=http_client_appengine.HttpClientAppengine())) 138 http_client_appengine.HttpClientAppengine(), repo_url))
134 content = deps_downloader.Load( 139 content = deps_downloader.Load(
135 'http://chrome-internal', '50.0.1234.0', 'DEPS') 140 'http://chrome-internal', '50.0.1234.0', 'DEPS')
136 self.assertEqual(content, 'Dummy DEPS content') 141 self.assertEqual(content, 'Dummy DEPS content')
137 142
138 self.assertRaisesRegexp( 143 self.assertRaisesRegexp(
139 Exception, 144 Exception,
140 'Failed to pull DEPS file from http://chrome, at revision 50.0.1234.1.', 145 'Failed to pull DEPS file from http://chrome, at revision 50.0.1234.1.',
141 self.deps_downloader.Load, 146 self.deps_downloader.Load,
142 'http://chrome', '50.0.1234.1', 'DEPS') 147 'http://chrome', '50.0.1234.1', 'DEPS')
143 148
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 'src/', 292 'src/',
288 'https://chromium.googlesource.com/chromium/src.git', '4', '5'), 293 'https://chromium.googlesource.com/chromium/src.git', '4', '5'),
289 } 294 }
290 self.assertEqual(self.chrome_dep_fetcher.GetDependencyRollsDict( 295 self.assertEqual(self.chrome_dep_fetcher.GetDependencyRollsDict(
291 '4', '5', 'all'), expected_deps_rolls_dict) 296 '4', '5', 'all'), expected_deps_rolls_dict)
292 297
293 def testIsChromeVersion(self): 298 def testIsChromeVersion(self):
294 self.assertTrue(chrome_dependency_fetcher.IsChromeVersion('50.0.1234.1')) 299 self.assertTrue(chrome_dependency_fetcher.IsChromeVersion('50.0.1234.1'))
295 self.assertFalse(chrome_dependency_fetcher.IsChromeVersion('a.b.c.e')) 300 self.assertFalse(chrome_dependency_fetcher.IsChromeVersion('a.b.c.e'))
296 self.assertFalse(chrome_dependency_fetcher.IsChromeVersion('5.021.2.0.123')) 301 self.assertFalse(chrome_dependency_fetcher.IsChromeVersion('5.021.2.0.123'))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698