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 import unittest | 7 import unittest |
7 import test_urlfetch | 8 import test_urlfetch |
8 | 9 |
9 from branch_utility import BranchUtility | |
10 | |
11 class BranchUtilityTest(unittest.TestCase): | 10 class BranchUtilityTest(unittest.TestCase): |
12 def testGetChannelNameFromPath(self): | 11 def testGetChannelNameFromPath(self): |
13 b_util = BranchUtility(test_urlfetch) | 12 self.assertEquals('dev', branch_utility.GetChannelNameFromPath( |
14 self.assertEquals('dev', b_util.GetChannelNameFromPath( | |
15 'dev/hello/stuff.html')) | 13 'dev/hello/stuff.html')) |
16 self.assertEquals('beta', b_util.GetChannelNameFromPath( | 14 self.assertEquals('beta', branch_utility.GetChannelNameFromPath( |
17 'beta/hello/stuff.html')) | 15 'beta/hello/stuff.html')) |
18 self.assertEquals('trunk', b_util.GetChannelNameFromPath( | 16 self.assertEquals('trunk', branch_utility.GetChannelNameFromPath( |
19 'trunk/hello/stuff.html')) | 17 'trunk/hello/stuff.html')) |
20 self.assertEquals('stable', b_util.GetChannelNameFromPath( | 18 self.assertEquals('stable', branch_utility.GetChannelNameFromPath( |
21 'hello/stuff.html')) | 19 'hello/stuff.html')) |
22 self.assertEquals('stable', b_util.GetChannelNameFromPath( | 20 self.assertEquals('stable', branch_utility.GetChannelNameFromPath( |
23 'hello/dev/stuff.html')) | 21 'hello/dev/stuff.html')) |
24 | 22 |
25 def testGetBranchNumberForChannelName(self): | 23 def testGetBranchNumberForChannelName(self): |
26 b_util = BranchUtility(test_urlfetch) | 24 base_path = 'branch_utility/first.json' |
27 b_util.SetURL('branch_utility/first.json') | |
28 self.assertEquals('1132', | 25 self.assertEquals('1132', |
29 b_util.GetBranchNumberForChannelName('dev')) | 26 branch_utility.GetBranchNumberForChannelName('dev', |
| 27 test_urlfetch, |
| 28 base_path)) |
30 self.assertEquals('1084', | 29 self.assertEquals('1084', |
31 b_util.GetBranchNumberForChannelName('beta')) | 30 branch_utility.GetBranchNumberForChannelName('beta', |
| 31 test_urlfetch, |
| 32 base_path)) |
32 self.assertEquals('1234', | 33 self.assertEquals('1234', |
33 b_util.GetBranchNumberForChannelName('stable')) | 34 branch_utility.GetBranchNumberForChannelName('stable', |
| 35 test_urlfetch, |
| 36 base_path)) |
34 self.assertEquals('trunk', | 37 self.assertEquals('trunk', |
35 b_util.GetBranchNumberForChannelName('trunk')) | 38 branch_utility.GetBranchNumberForChannelName('trunk', |
| 39 test_urlfetch, |
| 40 base_path)) |
36 | 41 |
37 if __name__ == '__main__': | 42 if __name__ == '__main__': |
38 unittest.main() | 43 unittest.main() |
OLD | NEW |