| OLD | NEW |
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 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 from branch_utility import BranchUtility, ChannelInfo | 5 from branch_utility import BranchUtility, ChannelInfo |
| 6 from test_data.canned_data import (CANNED_BRANCHES, CANNED_CHANNELS) | 6 from test_data.canned_data import (CANNED_BRANCHES, CANNED_CHANNELS) |
| 7 | 7 |
| 8 | 8 |
| 9 class TestBranchUtility(object): | 9 class TestBranchUtility(object): |
| 10 '''Mimics BranchUtility to return valid-ish data without needing omahaproxy | 10 '''Mimics BranchUtility to return valid-ish data without needing omahaproxy |
| 11 data. | 11 data. |
| 12 ''' | 12 ''' |
| 13 | 13 |
| 14 def __init__(self, versions, channels): | 14 def __init__(self, versions, channels): |
| 15 ''' Parameters: |version| is a mapping of versions to branches, and | 15 ''' Parameters: |version| is a mapping of versions to branches, and |
| 16 |channels| is a mapping of channels to versions. | 16 |channels| is a mapping of channels to versions. |
| 17 ''' | 17 ''' |
| 18 self._versions = versions | 18 self._versions = versions |
| 19 self._channels = channels | 19 self._channels = channels |
| 20 | 20 |
| 21 @staticmethod | 21 @staticmethod |
| 22 def CreateWithCannedData(): | 22 def CreateWithCannedData(): |
| 23 '''Returns a TestBranchUtility that uses 'canned' test data pulled from | 23 '''Returns a TestBranchUtility that uses 'canned' test data pulled from |
| 24 older branches of SVN data. | 24 older branches of SVN data. |
| 25 ''' | 25 ''' |
| 26 return TestBranchUtility(CANNED_BRANCHES, CANNED_CHANNELS) | 26 return TestBranchUtility(CANNED_BRANCHES, CANNED_CHANNELS) |
| 27 | 27 |
| 28 def GetAllChannelInfo(self): | 28 def GetAllChannelInfo(self): |
| 29 return tuple(self.GetChannelInfo(channel) | 29 return tuple(self.GetChannelInfo(channel) |
| 30 for channel in BranchUtility.GetAllChannelNames()) | 30 for channel in BranchUtility.GetAllChannelNames()) |
| 31 | 31 |
| 32 def GetChannelInfo(self, channel): | 32 def GetChannelInfo(self, channel): |
| 33 version = self._channels[channel] | 33 version = self._channels[channel] |
| 34 return ChannelInfo(channel, self.GetBranchForVersion(version), version) | 34 return ChannelInfo(channel, self.GetBranchForVersion(version), version) |
| 35 | 35 |
| 36 def GetStableChannelInfo(self, version): | 36 def GetStableChannelInfo(self, version): |
| 37 return ChannelInfo('stable', self.GetBranchForVersion(version), version) | 37 return ChannelInfo('stable', self.GetBranchForVersion(version), version) |
| 38 | 38 |
| 39 def GetBranchForVersion(self, version): | 39 def GetBranchForVersion(self, version): |
| 40 return self._versions[version] | 40 return self._versions[version] |
| (...skipping 17 matching lines...) Expand all Loading... |
| 58 | 58 |
| 59 def Newer(self, channel_info): | 59 def Newer(self, channel_info): |
| 60 versions = self._versions.keys() | 60 versions = self._versions.keys() |
| 61 index = versions.index(channel_info.version) | 61 index = versions.index(channel_info.version) |
| 62 if not index: | 62 if not index: |
| 63 return None | 63 return None |
| 64 version = versions[index - 1] | 64 version = versions[index - 1] |
| 65 return ChannelInfo(self.GetChannelForVersion(version), | 65 return ChannelInfo(self.GetChannelForVersion(version), |
| 66 self.GetBranchForVersion(version), | 66 self.GetBranchForVersion(version), |
| 67 version) | 67 version) |
| OLD | NEW |