| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2014 The Chromium Authors. All rights reserved. | 2 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 import base64 | 6 import base64 |
| 7 import json | 7 import json |
| 8 import unittest | 8 import unittest |
| 9 | 9 |
| 10 from extensions_paths import SERVER2 | 10 from extensions_paths import SERVER2 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 | 40 |
| 41 | 41 |
| 42 class DownloadError(Exception): | 42 class DownloadError(Exception): |
| 43 pass | 43 pass |
| 44 | 44 |
| 45 | 45 |
| 46 class _FakeGitilesFetcher(object): | 46 class _FakeGitilesFetcher(object): |
| 47 def __init__(self, fs): | 47 def __init__(self, fs): |
| 48 self._fs = fs | 48 self._fs = fs |
| 49 | 49 |
| 50 def FetchAsync(self, url): | 50 def FetchAsync(self, url, access_token=None): |
| 51 def resolve(): | 51 def resolve(): |
| 52 assert '?' in url | 52 assert '?' in url |
| 53 if url == _BASE_URL + '?format=JSON': | 53 if url == _BASE_URL + '?format=JSON': |
| 54 return _Response(json.dumps({'commit': 'a_commit'})) | 54 return _Response(json.dumps({'commit': 'a_commit'})) |
| 55 path, fmt = url.split('?') | 55 path, fmt = url.split('?') |
| 56 # Fetch urls are of the form <base_url>/<path>. We only want <path>. | 56 # Fetch urls are of the form <base_url>/<path>. We only want <path>. |
| 57 path = path.split('/', 1)[1] | 57 path = path.split('/', 1)[1] |
| 58 if path == _REAL_DATA_DIR: | 58 if path == _REAL_DATA_DIR: |
| 59 return _Response(ReadFile(*_TEST_DATA)) | 59 return _Response(ReadFile(*_TEST_DATA)) |
| 60 # ALWAYS skip not found here. | 60 # ALWAYS skip not found here. |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 other_gitiles_fs = GitilesFileSystem.Create(commit='abcdefghijklmnop') | 154 other_gitiles_fs = GitilesFileSystem.Create(commit='abcdefghijklmnop') |
| 155 self.assertEqual(self._gitiles_fs.GetIdentity(), | 155 self.assertEqual(self._gitiles_fs.GetIdentity(), |
| 156 other_gitiles_fs.GetIdentity()) | 156 other_gitiles_fs.GetIdentity()) |
| 157 | 157 |
| 158 yet_another_gitiles_fs = GitilesFileSystem.Create(branch='different') | 158 yet_another_gitiles_fs = GitilesFileSystem.Create(branch='different') |
| 159 self.assertNotEqual(self._gitiles_fs.GetIdentity(), | 159 self.assertNotEqual(self._gitiles_fs.GetIdentity(), |
| 160 yet_another_gitiles_fs.GetIdentity()) | 160 yet_another_gitiles_fs.GetIdentity()) |
| 161 | 161 |
| 162 if __name__ == '__main__': | 162 if __name__ == '__main__': |
| 163 unittest.main() | 163 unittest.main() |
| OLD | NEW |