| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2013 The Chromium Authors. All rights reserved. | 2 # Copyright 2013 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 from copy import deepcopy |
| 6 import unittest | 7 import unittest |
| 7 | 8 |
| 8 from host_file_system_creator import HostFileSystemCreator | 9 from host_file_system_provider import HostFileSystemProvider |
| 9 from host_file_system_creator_test import ConstructorForTest | |
| 10 from host_file_system_iterator import HostFileSystemIterator | 10 from host_file_system_iterator import HostFileSystemIterator |
| 11 from object_store_creator import ObjectStoreCreator | 11 from object_store_creator import ObjectStoreCreator |
| 12 from test_branch_utility import TestBranchUtility | 12 from test_branch_utility import TestBranchUtility |
| 13 from test_data.canned_data import CANNED_API_FILE_SYSTEM_DATA |
| 14 from test_file_system import TestFileSystem |
| 13 | 15 |
| 14 | 16 |
| 15 def _GetIterationTracker(version): | 17 def _GetIterationTracker(version): |
| 16 '''Adds the ChannelInfo object from each iteration to a list, and signals the | 18 '''Adds the ChannelInfo object from each iteration to a list, and signals the |
| 17 loop to stop when |version| is reached. | 19 loop to stop when |version| is reached. |
| 18 ''' | 20 ''' |
| 19 iterations = [] | 21 iterations = [] |
| 20 def callback(file_system, channel_info): | 22 def callback(file_system, channel_info): |
| 21 if channel_info.version == version: | 23 if channel_info.version == version: |
| 22 return False | 24 return False |
| 23 iterations.append(channel_info) | 25 iterations.append(channel_info) |
| 24 return True | 26 return True |
| 25 return (iterations, callback) | 27 return (iterations, callback) |
| 26 | 28 |
| 27 | 29 |
| 28 class HostFileSystemIteratorTest(unittest.TestCase): | 30 class HostFileSystemIteratorTest(unittest.TestCase): |
| 29 | 31 |
| 30 def setUp(self): | 32 def setUp(self): |
| 31 host_file_system_creator = HostFileSystemCreator( | 33 def host_file_system_constructor(branch, **optargs): |
| 34 return TestFileSystem(deepcopy(CANNED_API_FILE_SYSTEM_DATA[branch])) |
| 35 host_file_system_provider = HostFileSystemProvider( |
| 32 ObjectStoreCreator.ForTest(), | 36 ObjectStoreCreator.ForTest(), |
| 33 constructor_for_test=ConstructorForTest) | 37 constructor_for_test=host_file_system_constructor) |
| 34 self._branch_utility = TestBranchUtility.CreateWithCannedData() | 38 self._branch_utility = TestBranchUtility.CreateWithCannedData() |
| 35 self._iterator = HostFileSystemIterator( | 39 self._iterator = HostFileSystemIterator( |
| 36 host_file_system_creator, | 40 host_file_system_provider, |
| 37 host_file_system_creator.Create('trunk'), | |
| 38 self._branch_utility) | 41 self._branch_utility) |
| 39 | 42 |
| 40 def _GetStableChannelInfo(self,version): | 43 def _GetStableChannelInfo(self,version): |
| 41 return self._branch_utility.GetStableChannelInfo(version) | 44 return self._branch_utility.GetStableChannelInfo(version) |
| 42 | 45 |
| 43 def _GetChannelInfo(self, channel_name): | 46 def _GetChannelInfo(self, channel_name): |
| 44 return self._branch_utility.GetChannelInfo(channel_name) | 47 return self._branch_utility.GetChannelInfo(channel_name) |
| 45 | 48 |
| 46 def testAscending(self): | 49 def testAscending(self): |
| 47 # Start at |stable| version 5, and move up towards |trunk|. | 50 # Start at |stable| version 5, and move up towards |trunk|. |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 self._GetStableChannelInfo(16), | 171 self._GetStableChannelInfo(16), |
| 169 self._GetStableChannelInfo(15), | 172 self._GetStableChannelInfo(15), |
| 170 self._GetStableChannelInfo(14), | 173 self._GetStableChannelInfo(14), |
| 171 self._GetStableChannelInfo(13), | 174 self._GetStableChannelInfo(13), |
| 172 self._GetStableChannelInfo(12), | 175 self._GetStableChannelInfo(12), |
| 173 self._GetStableChannelInfo(11)], iterations) | 176 self._GetStableChannelInfo(11)], iterations) |
| 174 | 177 |
| 175 | 178 |
| 176 if __name__ == '__main__': | 179 if __name__ == '__main__': |
| 177 unittest.main() | 180 unittest.main() |
| OLD | NEW |