| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 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 branch_utility | 6 from branch_utility import BranchUtility |
| 7 from fake_url_fetcher import FakeUrlFetcher |
| 8 from in_memory_memcache import InMemoryMemcache |
| 7 import unittest | 9 import unittest |
| 8 import test_urlfetch | |
| 9 | 10 |
| 10 class BranchUtilityTest(unittest.TestCase): | 11 class BranchUtilityTest(unittest.TestCase): |
| 12 def setUp(self): |
| 13 self._branch_util = BranchUtility('branch_utility/first.json', |
| 14 'stable', |
| 15 FakeUrlFetcher('test_data'), |
| 16 InMemoryMemcache()) |
| 17 |
| 11 def testSplitChannelNameFromPath(self): | 18 def testSplitChannelNameFromPath(self): |
| 12 self.assertEquals(('dev', 'hello/stuff.html'), | 19 self.assertEquals(('dev', 'hello/stuff.html'), |
| 13 branch_utility.SplitChannelNameFromPath( | 20 self._branch_util.SplitChannelNameFromPath( |
| 14 'dev/hello/stuff.html')) | 21 'dev/hello/stuff.html')) |
| 15 self.assertEquals(('beta', 'hello/stuff.html'), | 22 self.assertEquals(('beta', 'hello/stuff.html'), |
| 16 branch_utility.SplitChannelNameFromPath( | 23 self._branch_util.SplitChannelNameFromPath( |
| 17 'beta/hello/stuff.html')) | 24 'beta/hello/stuff.html')) |
| 18 self.assertEquals(('trunk', 'hello/stuff.html'), | 25 self.assertEquals(('trunk', 'hello/stuff.html'), |
| 19 branch_utility.SplitChannelNameFromPath( | 26 self._branch_util.SplitChannelNameFromPath( |
| 20 'trunk/hello/stuff.html')) | 27 'trunk/hello/stuff.html')) |
| 21 self.assertEquals(('stable', 'hello/stuff.html'), | 28 self.assertEquals(('stable', 'hello/stuff.html'), |
| 22 branch_utility.SplitChannelNameFromPath( | 29 self._branch_util.SplitChannelNameFromPath( |
| 23 'hello/stuff.html')) | 30 'hello/stuff.html')) |
| 24 self.assertEquals(('stable', 'hello/dev/stuff.html'), | 31 self.assertEquals(('stable', 'hello/dev/stuff.html'), |
| 25 branch_utility.SplitChannelNameFromPath( | 32 self._branch_util.SplitChannelNameFromPath( |
| 26 'hello/dev/stuff.html')) | 33 'hello/dev/stuff.html')) |
| 27 | 34 |
| 28 def testGetBranchNumberForChannelName(self): | 35 def testGetBranchNumberForChannelName(self): |
| 29 base_path = 'branch_utility/first.json' | |
| 30 self.assertEquals('1132', | 36 self.assertEquals('1132', |
| 31 branch_utility.GetBranchNumberForChannelName('dev', | 37 self._branch_util.GetBranchNumberForChannelName('dev')) |
| 32 test_urlfetch, | |
| 33 base_path)) | |
| 34 self.assertEquals('1084', | 38 self.assertEquals('1084', |
| 35 branch_utility.GetBranchNumberForChannelName('beta', | 39 self._branch_util.GetBranchNumberForChannelName('beta')) |
| 36 test_urlfetch, | |
| 37 base_path)) | |
| 38 self.assertEquals('1234', | 40 self.assertEquals('1234', |
| 39 branch_utility.GetBranchNumberForChannelName('stable', | 41 self._branch_util.GetBranchNumberForChannelName('stable')) |
| 40 test_urlfetch, | |
| 41 base_path)) | |
| 42 self.assertEquals('trunk', | 42 self.assertEquals('trunk', |
| 43 branch_utility.GetBranchNumberForChannelName('trunk', | 43 self._branch_util.GetBranchNumberForChannelName('trunk')) |
| 44 test_urlfetch, | |
| 45 base_path)) | |
| 46 | 44 |
| 47 if __name__ == '__main__': | 45 if __name__ == '__main__': |
| 48 unittest.main() | 46 unittest.main() |
| OLD | NEW |