Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(152)

Side by Side Diff: chrome/common/extensions/docs/server2/branch_utility_test.py

Issue 10387225: Die build.py, Die: Part 1 (BranchUtility and SubversionFetcher) (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Unit tests Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 #!/usr/bin/env python
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
4 # found in the LICENSE file.
5
6 import branch_utility
7 import unittest
8
9 def ReadFile(filename):
10 with open(filename, 'r') as f:
11 return f.read()
12
13 class MockBranchUtility(branch_utility.BranchUtility):
14 def _FetchURL(self, url):
15 return ReadFile('test_data/' + url)
16
17 class BranchUtilityTest(unittest.TestCase):
18 def testGetChannelNameFromURL(self):
19 b_util = MockBranchUtility()
20 self.assertEquals('dev', b_util.GetChannelNameFromURL(
21 'dev/hello/stuff.html'))
22 self.assertEquals('beta', b_util.GetChannelNameFromURL(
23 'beta/hello/stuff.html'))
24 self.assertEquals('trunk', b_util.GetChannelNameFromURL(
25 'trunk/hello/stuff.html'))
26 self.assertEquals('stable', b_util.GetChannelNameFromURL(
27 'hello/stuff.html'))
28 self.assertEquals('stable', b_util.GetChannelNameFromURL(
29 'hello/dev/stuff.html'))
30
31 def testGetBranchNumberForURL(self):
32 b_util = MockBranchUtility()
33 b_util.SetURL('branch_number/first.json')
34 self.assertEquals('1132', b_util.GetBranchNumberForURL('dev/stuff.html'))
35 self.assertEquals('1084', b_util.GetBranchNumberForURL('beta/stuff.html'))
36 self.assertEquals('1234', b_util.GetBranchNumberForURL('stuff.html'))
37 self.assertEquals('trunk', b_util.GetBranchNumberForURL('trunk/stuff.html'))
38
39 if __name__ == '__main__':
40 unittest.main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698